Jump to content

Javascript isn't seeing my variables!

- - - - -

  • Please log in to reply
6 replies to this topic

#1
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
Ok, so Javascript doesn't want to see my variable, here is part of the script.js file:
35: function send_input(formInput)	{

36: hide_input();

37: var inputName = formInput.name.value;
And my HTML:
<form name='input' action='#' method='get'>

Subject Name: <input type='text' name='name' value='name'>

Your Name: <input type='text' name='author' value='author'>

<input type='submit' onclick='send_input()'>

</form>

<a href='#' onclick='hide_input(this.form)'>Hide</a>
Please don't tell me to use Jslint.
But firebug is telling me it cannot see my formInput value!?!
Here:

Quote

[18:09:29.386] formInput is undefined @ http://localhost/tes...st/script.js:37

Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Change your onclick to this:

<input type='submit' onclick='send_input([B]this.form[/B])'>



#3
Heaven1977

Heaven1977

    Newbie

  • Members
  • PipPip
  • 10 posts
onclick should be written as following to run

onclick="hide_input(this.form);"
or
onclick="javascript:hide_input(this.form);"

also refer to document.input =====> to refer to this form :)

check and tell me


bbqroast said:

Ok, so Javascript doesn't want to see my variable, here is part of the script.js file:
35: function send_input(formInput)	{

36: hide_input();

37: var inputName = formInput.name.value;
And my HTML:
<form name='input' action='#' method='get'>

Subject Name: <input type='text' name='name' value='name'>

Your Name: <input type='text' name='author' value='author'>

<input type='submit' onclick='send_input()'>

</form>

<a href='#' onclick='hide_input(this.form)'>Hide</a>
Please don't tell me to use Jslint.
But firebug is telling me it cannot see my formInput value!?!
Here:


#4
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
...
Confused I'll try it now
Oops thats the type of embarrassing mistake I make,
still getting same error through!
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#5
oldhendra

oldhendra

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
Perhaps
<input type='submit' onclick='send_input(document.forms["input"])'>
?
But... doesn't it confusing to have it named as "input" ?

#6
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
Oh gawd now i'm getting confused,
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#7
oldhendra

oldhendra

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
The line
<input type='submit' onclick='send_input(document.forms["input"])'>
is an alternative to:
 <input type='submit' onclick='send_input(this.form)'>
given by wim DC. Both should give the same result.

What errors did your browser report (beside the one firebug gave) ?
Are you using iframes/ frames? Probably you should show more code here...

Hendra




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users