Connecting Tech Pros Worldwide Help | Site Map

get form value

  #1  
Old August 16th, 2006, 09:25 PM
Jon Paal
Guest
 
Posts: n/a
onClick can't get the search input value , what am I missing ?

....
<input type="text" value="Search" size="10" >
<input type="submit" name="Submit" value="Go" class="form"
onClick= return "alert( document.forms[this.formname].elements['Search'].value );">

....


  #2  
Old August 16th, 2006, 09:55 PM
Randy Webb
Guest
 
Posts: n/a

re: get form value


Jon Paal said the following on 8/16/2006 4:33 PM:
Quote:
onClick can't get the search input value , what am I missing ?
>
....
<input type="text" value="Search" size="10" >
<input type="submit" name="Submit" value="Go" class="form"
onClick= return "alert( document.forms[this.formname].elements['Search'].value );">
onclick="alert(this.form.elements['Search'].value)"

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
  #3  
Old August 16th, 2006, 10:15 PM
Evertjan.
Guest
 
Posts: n/a

re: get form value


Randy Webb wrote on 16 aug 2006 in comp.lang.javascript:
Quote:
Jon Paal said the following on 8/16/2006 4:33 PM:
Quote:
>onClick can't get the search input value , what am I missing ?
>>
>....
> <input type="text" value="Search" size="10" >
<inputmust have a name to be used
Quote:
Quote:
> <input type="submit" name="Submit" value="Go" class="form"
>onClick= return "alert(
>document.forms[this.formname].elements['Search'].value );">
1 alert does not return a usable value
2 do not use onclick here, but onsubmit in the <form>
Quote:
>
onclick="alert(this.form.elements['Search'].value)"
>
Try:

<form onsubmit='alert(this.elements["Search"].value);return false'>
<input type='text' name='Search' value='abc' >
<input type='submit' name='Submit' value='Go'>
</form>

the "return false" is only necessary if you do not want to submit ageter
the alert.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
  #4  
Old August 16th, 2006, 10:25 PM
Matt Kruse
Guest
 
Posts: n/a

re: get form value


Jon Paal wrote:
Quote:
onClick can't get the search input value , what am I missing ?
<input type="text" value="Search" size="10" >
<input type="submit" name="Submit" value="Go" class="form"
onClick= return "alert(
document.forms[this.formname].elements['Search'].value );">
<input type="submit" name="Submit" value="Go" class="form"
onClick="alert(this.form.Search.value);">

And then be sure to put a name="Search" in your input box, as it currently
lacks a name attribute.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Form Value Through JS ziycon answers 3 February 12th, 2009 01:39 AM
get form value from another page mentor answers 1 February 13th, 2008 12:28 PM
How can I get a form value? Oney answers 2 November 18th, 2005 12:39 PM
MS Access front end to SQL Server problem passing Form value to Report rickcheney@gmail.com answers 7 July 23rd, 2005 08:44 AM