Jump to content

How to do a Post-type Submit when user clicks a radio button?


RogerInHawaii

Recommended Posts

I want to effectively do a Post type submit to the very same page when the user clicks on a particular radio button. Of course, I also want it to recognize the click (i.e. checkmarking the radio button) first so the new status of that readio button gets properly Posted.

 

How do I do that?

Ah, found it.

 

<form id="Form1" action="<?=$_SERVER['PHP_SELF'] ?>" method="post">
<input type="radio" onchange="document.getElementById('Form1').submit()">
</form>

 

You need to give your form an "id", then you can use the javascript onchange function. Just use the code above as a reference.

Ah, found it.

 

<form id="Form1" action="<?=$_SERVER['PHP_SELF'] ?>" method="post">
<input type="radio" onchange="document.getElementById('Form1').submit()">
</form>

 

You need to give your form an "id", then you can use the javascript onchange function. Just use the code above as a reference.

 

are sure thats correct coz I think your dealing with html dom

i think its something like this

<input type="radio" onchange="javascript:document.getElementById('Form1').submit();">

 

or

javascript here----

document.getElementById('Form1').submit()

----

 

<input type="radio" onchange="submit()">

 

isnt it like that

All those ways might work...maybe there isn't a wrong way to do it between them all? I got the script I posted on a tutorial site, and tested it...so it works fine, I don't see why it wouldn't be a valid way.

Yes, I want the radio button to do the submitting stuff, just as if the user had the a standard Submit button. What I want to accomplish is to have certain display fields updated when the radio button is clicked. In particular, I'm updating a "cost" field indicating how much the user has selected to purchase. I'll be applying this to checkboxes as well, but my first issue is with the radio button. I'm assuming that whatever solution applies to the radio button will also apply to the checkboxes.

 

I'm aware that I could require the user to hit some kind of Submit button in order to updatethe page, but it would be sooooo nice if I could make it happen automatically when he histthe radio button (or checkbox, or other control that requires a refresh of the data on the page).

 

 

The tutorial site? Sorry, but I have no idea how I would find it again. I typed in so many things on google, and searched through so many sites that it would take me forever to find.

 

You don't need it anyways, I copied and pasted the exact code that the tutorial gave.

i think its something like this

<input type="radio" onchange="javascript:document.getElementById('Form1').submit();">

 

I did it as

<input type="radio" onClick="javascript:document.getElementById('Form1').submit();">

 

and it works like a charm. Thank you for the advice.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.