RogerInHawaii Posted June 19, 2007 Share Posted June 19, 2007 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? Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 19, 2007 Share Posted June 19, 2007 what?? you want a radio button to do the submitting stuff or select a radio button then click the submit button which is the usual thing ASTIG!!! Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2007 Share Posted June 20, 2007 This would take javascript....let me see if I can find it on google for you. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2007 Share Posted June 20, 2007 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. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 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 Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2007 Share Posted June 20, 2007 Yes, it's correct....I even tested it myself, it works. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 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 Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2007 Share Posted June 20, 2007 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. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 can you show the site Any way dont get mad at me I was just giving my idea the site plss. I havent use the code you posted if it works for you NP but site i want to learn the other way Quote Link to comment Share on other sites More sharing options...
RogerInHawaii Posted June 20, 2007 Author Share Posted June 20, 2007 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). Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 so the issue is before submitting??? then javascript can do that if you dont want to refresh the page when you click radio then u want to automatically check the chk boxes??? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2007 Share Posted June 20, 2007 You should probably post what you are trying to do in the JavaScript forum, you will get better replies, and more help =] Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 pocobueno1388 site plss Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2007 Share Posted June 20, 2007 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. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 i dont mean any thing bro ijust thought i will learn new from what you have Quote Link to comment Share on other sites More sharing options...
RogerInHawaii Posted June 20, 2007 Author Share Posted June 20, 2007 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. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 ya !! ASTIG!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.