471,887 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to submit a form on a radio click

HD
Hi.

I have an asp page with radio buttons and a combobox... when the user clicks
a radio button, I want the form to submit so I can execute the ASP code in
order to change the list shown in the combobox... I have 2 radiobuttons:

<input type="radio" name="terriprod" value="E">E
<input type="radio" name="terriprod" value="D">D

I have tried adding an OnClick event to each of the radio button...
<input type="radio" name="terriprod" value="D"
onclick="javascript:document.forms[0].submit();">D
but it does not work...

I have then tried to put each of the radio button into an anchor...
<a href="javascript:document.forms[0].submit();"><input type="radio"
name="terriprod" value="D"></a>D
but it does not work...

I have then tried to add to the onclick event a javascript function
<input type="radio" name="terriprod" value="D"
onclick="javascript:Verif(document.forms[0]);">D
and in the Verif function I try to submit the form but it does not work...

I have also tried:
I have then tried to add to the onclick event a javascript function
<input type="radio" name="terriprod" value="D" onclick="javascript:if
Verif(document.forms[0]) {document.forms[0].submit();};">D

But it does not work...

Can someone help me.

HDumas
Jul 23 '05 #1
6 18602
Hello

Try this: <input type="radio" name="terriprod" value="D"
onclick="this.form.submit();">D

Anyway, the onclick events you added should work as well...What browser
you're using?
Perhaps you have other script errors in your page...

--
Elias
"HD" <du**@hotmail.com> wrote in message
news:Dn*********************@news20.bellglobal.com ...
Hi.

I have an asp page with radio buttons and a combobox... when the user
clicks
a radio button, I want the form to submit so I can execute the ASP code in
order to change the list shown in the combobox... I have 2 radiobuttons:

<input type="radio" name="terriprod" value="E">E
<input type="radio" name="terriprod" value="D">D

I have tried adding an OnClick event to each of the radio button...
<input type="radio" name="terriprod" value="D"
onclick="javascript:document.forms[0].submit();">D
but it does not work...

I have then tried to put each of the radio button into an anchor...
<a href="javascript:document.forms[0].submit();"><input type="radio"
name="terriprod" value="D"></a>D
but it does not work...

I have then tried to add to the onclick event a javascript function
<input type="radio" name="terriprod" value="D"
onclick="javascript:Verif(document.forms[0]);">D
and in the Verif function I try to submit the form but it does not work...

I have also tried:
I have then tried to add to the onclick event a javascript function
<input type="radio" name="terriprod" value="D" onclick="javascript:if
Verif(document.forms[0]) {document.forms[0].submit();};">D

But it does not work...

Can someone help me.

HDumas

Jul 23 '05 #2
HD
Hi and thanks but I have tried your suggestion...it does not work... it does
submit the form, but it does not go through the Verif function.
When the user clicks on the radio button, I need it to do the Verif function
and then submit the form.

..... I have Internet Explorer on Windows XP...
"lallous" <la*****@lgwm.org> a écrit dans le message de
news:30*************@uni-berlin.de...
Hello

Try this: <input type="radio" name="terriprod" value="D"
onclick="this.form.submit();">D

Anyway, the onclick events you added should work as well...What browser
you're using?
Perhaps you have other script errors in your page...

--
Elias
"HD" <du**@hotmail.com> wrote in message
news:Dn*********************@news20.bellglobal.com ...
Hi.

I have an asp page with radio buttons and a combobox... when the user
clicks
a radio button, I want the form to submit so I can execute the ASP code in order to change the list shown in the combobox... I have 2 radiobuttons:
<input type="radio" name="terriprod" value="E">E
<input type="radio" name="terriprod" value="D">D

I have tried adding an OnClick event to each of the radio button...
<input type="radio" name="terriprod" value="D"
onclick="javascript:document.forms[0].submit();">D
but it does not work...

I have then tried to put each of the radio button into an anchor...
<a href="javascript:document.forms[0].submit();"><input type="radio"
name="terriprod" value="D"></a>D
but it does not work...

I have then tried to add to the onclick event a javascript function
<input type="radio" name="terriprod" value="D"
onclick="javascript:Verif(document.forms[0]);">D
and in the Verif function I try to submit the form but it does not work...
I have also tried:
I have then tried to add to the onclick event a javascript function
<input type="radio" name="terriprod" value="D" onclick="javascript:if
Verif(document.forms[0]) {document.forms[0].submit();};">D

But it does not work...

Can someone help me.

HDumas


Jul 23 '05 #3
HD wrote:
Hi and thanks but I have tried your suggestion...it does not work... it does
submit the form, but it does not go through the Verif function.
When the user clicks on the radio button, I need it to do the Verif function
and then submit the form.
Then call the Verif function and let Verif submit the form.

<form onsubmit="Verif();return false">

And then in Verif, submit the form.
..... I have Internet Explorer on Windows XP...


And your point is?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #4
You haven't posted your HTML (or enough of it) so, a guess: this usually
happens when someone does this -

<input type="submit" name="submit" />

...which over-writes the Form.submit() method. If so, just name that
button something else.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5
Rob B wrote:
You haven't posted your HTML (or enough of it) so, a guess: this usually
happens when someone does this -

<input type="submit" name="submit" />

...which over-writes the Form.submit() method. If so, just name that
button something else.


Let me quote part of the OP's response for you:

<quote>
Hi and thanks but I have tried your suggestion...it does not work... it
does submit the form, but it does not go through the Verif function.
</quote>

The form submits, but the form's onsubmit handler doesn't get called.
That is documented behavior. The solution, thats in my last post, is to
have the validation function submit the form and then call the
validation function onclick as well as onsubmit.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #6
Randy Webb wrote:
The form submits, but the form's onsubmit handler doesn't get called. That is documented behavior.

Thanks, I knew that - but where do you see, in the above, any trace of
an onsubmit handler (or a form tag, for that matter)?

Can you explain this:
I have then tried to add to the onclick event a javascript function
<input type="radio" name="terriprod" value="D"
onclick="javascript:Verif(document.forms[0]);">D
and in the Verif function I try to submit the form but it > does not work...
I have also tried:
I have then tried to add to the onclick event a javascript function
<input type="radio" name="terriprod" value="D" onclick="javascript:if
Verif(document.forms[0]) {document.forms[0].submit();};">D But it does not work...
As HDumas noted, they should have. The only way explicitly calling
Form.submit() will fail is if the method itself is over-written, a
common occurrence as a result of naming the submit button "submit". Yes,
I noticed he said "it does
submit the form..." but thought he might be mistaken as there is no
other likely explanation for the earlier observations.
The solution, thats in my last post...


Not necessarily the only one....

<form.....onsubmit="return Verif(this)">
<input type="radio" name="terriprod" value="E" />E
<input type="radio" name="terriprod" value="D"
onclick="if(Verif(this.form))this.form.submit()" />D
<input type="submit" />
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Carlo | last post: by
15 posts views Thread by JR | last post: by
4 posts views Thread by Sjon | last post: by
4 posts views Thread by houstoncity2004 | last post: by
8 posts views Thread by shandain | last post: by
1 post views Thread by ansc1 | last post: by
reply views Thread by YellowAndGreen | last post: by

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.