473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 );">

....
Aug 16 '06 #1
3 9066
Jon Paal said the following on 8/16/2006 4:33 PM:
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/
Aug 16 '06 #2
Randy Webb wrote on 16 aug 2006 in comp.lang.javascript:
Jon Paal said the following on 8/16/2006 4:33 PM:
>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
> <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>
>
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)
Aug 16 '06 #3
Jon Paal wrote:
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
Aug 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Pete..... | last post by:
Hi all. I have made a webpage where there is a webform where people can fill in their personel information: The code is below: I want to transfer the data to a postgreSQL database ( I have...
3
by: John | last post by:
Dear all, It been more than 3 days I am trying to debug this program, I interpret it using activePerl and it is giving (perl -wc code_process.pl) no error syntax but when I put it online, change...
4
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
4
by: Targa | last post by:
Trying to total some price fields in a form but doesnt work when all the referenced form fields dont exisit. This is for an invoice - pulled prom a database and the form doesnt always contain the...
4
by: Steve | last post by:
Hi everyone, I have a test page. When I press the button, it bring form.html, which is fine. When I press Enter key in the textbox, it gives me an error saying this.form.cmd is not an object. ...
1
by: googleboy | last post by:
Hi. I am writing up my own web form. I'm a bit of a newb, and read up many different how-tos and examples and documentaion. I finally had it working just great until I decided that I wanted to...
3
by: Bill | last post by:
I'm using the POST method to submit a simple form html page with yes/no and checkbox fields to an asp response page which stores the values in a new dim string, then uses it to build a new table...
2
by: sammiesue | last post by:
Hi, I have form with 2 autosummed textboxes ("total" and "casinototal"). I would like to have a grand total textbox ("grandtotal") get its value from summing "total" and "casinototal", but it...
3
by: blackrunner | last post by:
ERROR in my Query?! ERROR: Element GESCHLECHT is undefined in FORM. i think everything ok. Maby somebody can help me here Element GESCHLECHT is undefined in FORM. The error occurred...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.