Connecting Tech Pros Worldwide Help | Site Map

get form value

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 16th, 2006, 08:25 PM
Jon Paal
Guest
 
Posts: n/a
Default get form value

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, 08:55 PM
Randy Webb
Guest
 
Posts: n/a
Default 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, 09:15 PM
Evertjan.
Guest
 
Posts: n/a
Default 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, 09:25 PM
Matt Kruse
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.