473,385 Members | 1,409 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,385 software developers and data experts.

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 1552
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
6
by: Omar | last post by:
Hi, In a JSP I have the next: .... codigo = "<select name='" + nombre + "'>\n<option selected value='default'>Escoge</option><option value='todos'>Todos</option>"; if (miRS != null) while...
11
by: ddailey | last post by:
I have a select named "s" in a form named "f": By default only one of the options in the select appears on the page -- that is how I want it. What I'd like to do is simulate a click on the...
2
by: entfred | last post by:
I was experimenting with trying to select the same item in a select box twice in a row and found out that you need to do a refresh (view - refresh) in Internet Explorer. This is so you can click...
3
by: eholz1 | last post by:
Hello PHP programmers. I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a...
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
14
by: white lightning | last post by:
How to have <select onchange="this.form.submit()"and also a Submit button on one form? I have something like this: <form action="<?php $_SERVER; ?>" method="post"...
2
by: FlashCreations | last post by:
Hello, I am trying to use javascript to validate a form that has three select inputs. Here is the form: <form name="select" action="main.php" method="post" onsubmit="return ValidateSelect(this)"> ...
6
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.