Forum Moderators: open

Message Too Old, No Replies

option button that submits

How to submit the form with an option button click

         

oscarrgd

12:06 am on Apr 29, 2005 (gmt 0)

10+ Year Member



I am building a questionaire that has more then 400 two option questions. It will be handy for the user to just click the option and reload the page getting to the next question.

My form allready has the submit button but I want to press it when the user clicks one o the two options. Does someone know how to accomplish this?
Regards

ajkimoto

1:11 am on Apr 29, 2005 (gmt 0)

10+ Year Member



oscarrgd,

First of all, Welcome to Webmaster World!

As for your question, you can add a handler to the select's onchange event, which fires when the user changes the value of the option and submits the form. You should start with a 'please choose' option so that the user will have to change the option and fire the event. See below:

<form method="post" action="blank.htm">
<select onchange="document.forms[0].submit()">
<option value="">Please Choose</option>
<option value="yes">Yes</option>
<option value="no">No</option></select>
</form>

hope this helps,

ajkimoto

oscarrgd

1:29 am on Apr 29, 2005 (gmt 0)

10+ Year Member



Thanks, now I would like to do this with a couple of radio buttons, can you please help me?

ajkimoto

3:25 am on Apr 29, 2005 (gmt 0)

10+ Year Member



oscarrgd,

You can use the onclick event to house the event handler for radio buttons. So you might have something like this:

<form method="post" action="blank.htm">
<input type="radio name="rad1" value="yes" onclick="document.forms[0].submit()" />
<input type="radio name="rad1" value="no" onclick="document.forms[0].submit()" />
</form>

ajkimoto

oscarrgd

5:17 am on Apr 29, 2005 (gmt 0)

10+ Year Member



Thanks so much, this was great!
Is there a place to start learning Javascript?

ajkimoto

1:09 pm on Apr 29, 2005 (gmt 0)

10+ Year Member



oscarrgd,

I'll sticky you a couple of links that I have found useful.

ajkimoto