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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.