I am creating a form that has radio buttons and select tags.
I want some fields to be populated on the previous selection. For example if a radio button is selected, populate fields related to that selection and so on. I have scratched my head a lot on php and MySQL. I m nt a computer person. My question is this :
Do I have to create the form with all the fields added already and hide them and show then only when th respective selection is done? Is there an alternative to this ? Kindly describe any readings / tutorials for this.
Regarding the php part, il post a question in the php section.
I read simply JavaScript by Kevin Yank and Cameron Adams but as I said m nt a computer person so m doin al stupid things …
(I have read that it’s no longer necessary to use “selected=‘selected’”, you can just use “selected”, but I’ve not proved this for myself).
If you want to change the default selection of <select> and radio buttons you have to deal with the selectedIndex property (using JavaScript).
It’s not clear to me whether you want to pre-set the selects and radio buttons, or take the user selections and use them to put values into other form fields (such as text inputs or text areas) ? If you can tell me a bit more I’ll try to answer more fully.
If you want stuff to happen dynamically when you click a radio button (for example), you’ll need to use JavaScript for that.
PHP is interpreted on the server and will just serve up HTML to your browser, so cannot by definition, cause anything dynamic to happen on your page.
If this is what you want, it would be great if you could go into a little more detail.
If this is not what you want, then just forget I spoke
You can do a little fake-out where you just use javascript to submit the form when a radio is selected but only do full processing if button is submitted. Here’s a rough sample.