469,645 Members | 1,084 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

use a select as a submit button!

Is there a way to use a value of in the pick list as a submit button?
If I select a value in a drop down box, it will be submitted to the next page.
Jul 23 '05 #1
6 1494
reneecccwest wrote:
Is there a way to use a value of in the pick list as a submit button?
If I select a value in a drop down box, it will be submitted to the next
page.


You can use JavaScript to call the submit() method of the form onchange for
the select... but this is generally considered a bad idea.

1. You need a submit button anyway (JavaScript doesn't work universally)
2. The normal behaviour of select elements does not cause the page to
change. People might[1] change their mind and not want to make a selection
- but once they've started, they are rather stuck with it.

[1] Scratch that. They _will_.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Jul 23 '05 #2
Lee
reneecccwest said:

Is there a way to use a value of in the pick list as a submit button?
If I select a value in a drop down box, it will be submitted to the next page.


Yes. You had better be sure that all visitors have Javascript, though.

<html>
<body>

<form action="http://www.google.com/search">
<select name="q" onchange="this.form.submit()">
<option>Choose one...</option>
<option>javascript</option>
<option>onchange</option>
<option value="event+handler">event handler</option>
</select>
</form>

</body>
</html>

Jul 23 '05 #3
btw is there anyway i can define and get a value of this.form.submit()?

thanks again
RC

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4
re**********@hotmail.com (reneecccwest) wrote in message news:<c1**************************@posting.google. com>...
Is there a way to use a value of in the pick list as a submit button?
If I select a value in a drop down box, it will be submitted to the next page.


You can use any control, or any tag as a "submit". Simply put an
"onclick=DoSubmit()" clause in the tag. Then in the javascript
function "DoSubmit()", have lines that look like this:

DoSubmit()
{
form1.method=post
form1.action=NextPage.html
form1.submit()
}
Jul 23 '05 #5
bruce wrote:
re**********@hotmail.com (reneecccwest) wrote in message news:<c1**************************@posting.google. com>...
Is there a way to use a value of in the pick list as a submit button?
If I select a value in a drop down box, it will be submitted to the next page.

You can use any control, or any tag as a "submit". Simply put an
"onclick=DoSubmit()" clause in the tag. Then in the javascript
function "DoSubmit()", have lines that look like this:

DoSubmit()
{
form1.method=post
form1.action=NextPage.html
form1.submit()
}


Thats assuming the browser is IE.

document.forms['form1'].method = 'POST';
document.forms['form1'].action = 'NextPage.html';
document.forms['form1'].submit();

The method and action should be quoted so that script doesn't attempt to
interpret as a variable.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #6
Randy Webb <hi************@aol.com> wrote in message news:<Lt********************@comcast.com>...
bruce wrote:
re**********@hotmail.com (reneecccwest) wrote in message news:<c1**************************@posting.google. com>...
Is there a way to use a value of in the pick list as a submit button?
If I select a value in a drop down box, it will be submitted to the next page.

You can use any control, or any tag as a "submit". Simply put an
"onclick=DoSubmit()" clause in the tag. Then in the javascript
function "DoSubmit()", have lines that look like this:

DoSubmit()
{
form1.method=post
form1.action=NextPage.html
form1.submit()
}


Thats assuming the browser is IE.

document.forms['form1'].method = 'POST';
document.forms['form1'].action = 'NextPage.html';
document.forms['form1'].submit();

The method and action should be quoted so that script doesn't attempt to
interpret as a variable.


Thanks for the correction!
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Newbie | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.