Member Avatar for mihirpatel83

Hello everyone,

I am new to PHP to so please bear with me. I need suggestion to achieve a task.
I have to make a form where in initially there will be a combox box. Depending onthe selection ie value1, value2, value3 etc.......a sub form should open below the combo box.

This forms r different for different value...and at the end there will be a submit button to submit the form.

Can anyone tell me the how many ways this is possible and which is the efficient one.???

Thanks a lot in advance....

Recommended Answers

All 3 Replies

better use JQuery.
Write select box elements and use unique ID as well as value.

and use

$("#IDValue").change(funtion(){
// here write code for open or close new form.
});
Member Avatar for diafol

As mentioned this can be achieved via js (jQuery) only. No need for php unless the form to be shown needs some specific processing, e.g. extract data from DB before display.

Member Avatar for diafol

Coming back to this:

You could avoid Ajax totally if your forms are not dynamic. Just hide all the forms with css (e.g. class="hide" with the css rules to go with it), then your onselect attribute for the select field decides to hide all subforms then just show the one you want. Alternatively, you could store your forms in javascript and have them show in a <div>.

Personally, I'd use Ajax (jQuery flavour) - onselect calls a js function, with a parameter. The js function passes this to a php script via Ajax object, the html is passed back via Ajax response and finally js updates the <div> with the new content.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.