infiniphunk Posted July 6, 2009 Share Posted July 6, 2009 Hello, please forgive me if I've posted this in the wrong forum. Here is what I'm trying to do. I want to make a form who's content changes dynamically as the user selects options, such as from a drop-down menu or radio buttons. I've googled around and just can't find a good howto on how this is done. You guys know what I'm talking about, we've all seen pages on the web that do this. For instance, you select an option and the form immediately updates itself to show further form input options pertaining to that selection (that don't need to be shown if that option is not selected). From what I understand there is a java function that does this, and I'd be ok with doing it that way if I have to. What is this called? Otherwise I'd prefer to stay clear of java if I can do this using php alone. Is there no way to integrate a submit button into a radio button or a select option entry? Any ideas much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/164925-onchange-submitting-form/ Share on other sites More sharing options...
shergold Posted July 6, 2009 Share Posted July 6, 2009 i believe what you are looking for is javascript, there are many sites that provide free scripts for or tutorials on what you are looking for, google it. Good luck, shergold. Quote Link to comment https://forums.phpfreaks.com/topic/164925-onchange-submitting-form/#findComment-869682 Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 like so? <form name=form1 action=/index.php method=post> <input type=whatever onchange="document.form1.submit();"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/164925-onchange-submitting-form/#findComment-869686 Share on other sites More sharing options...
haku Posted July 6, 2009 Share Posted July 6, 2009 It's javascript not java. They are entirely different languages. You can do it with php, but it will require a page reload, and you will need to add a button if order to reload the page with the new form element. To do this, you just add a button that says something like 'add new form element', then check in php to see if that was the button that was submitted. If it was, then you add the new form element, and send it back to the user. Quote Link to comment https://forums.phpfreaks.com/topic/164925-onchange-submitting-form/#findComment-869689 Share on other sites More sharing options...
infiniphunk Posted July 6, 2009 Author Share Posted July 6, 2009 OK, thanks for your replies. Looks like I finally have a good excuse to go learn some javascript. I think what I'm looking for is something called 'onchange'. cheers Quote Link to comment https://forums.phpfreaks.com/topic/164925-onchange-submitting-form/#findComment-870076 Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 best site IMO http://www.w3schools.com/JS/default.asp and stuff like onchange, onclick etc are called 'events', just so you have a direction for googling goodluck! Quote Link to comment https://forums.phpfreaks.com/topic/164925-onchange-submitting-form/#findComment-870078 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.