Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit a form by the click of a radio button 2

Status
Not open for further replies.

EchoAlertcom

IS-IT--Management
Oct 8, 2002
239
US
Hello,

I have 3 sets of Radio Buttons with 2 radio buttons per set all on one page. Each set is in their own set of Form tags. I would like the form to be submitted when the radio button that is not currently select is selected. Like an On Off button set.

I know nothing about javascript so if you know how to help out please be very obvious about everything.

Sincerely,
Steve
 
Hello there,
It's a piece of cake :) Here is a sample script:

<form action=&quot; method=&quot;post&quot;>
Radio1 <input type=&quot;radio&quot; name=&quot;rd&quot; value=&quot;1&quot; onchange=&quot;form.submit()&quot;><br>
Radio2 <input type=&quot;radio&quot; name=&quot;rd&quot; value=&quot;2&quot; onchange=&quot;form.submit()&quot;>
</form>

You can use the event that you need (onchange, onclick, onselect, etc...)

Goodluck
 
Hi Steve

You can do this with the onclick event for the radio button like this:

onclick=&quot;document.forms[x].submit()&quot;

Replace the x with the number of the form you want to submit (numbering starts at 0).

A better way may be to call a function which submits the form in the same way (in case you want to do something else) but the above will work fine.

Remember that by making 3 seperate forms and submitting a specific one you will only submit information from that particular form.

Cheers
Richard
 
Thank you both.

Great explanations.

Sincerely,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top