I have a form in which user needs to input his height. I have two radio buttons to select the format in which the user wishes to input his height. one is "feet-inch" and another is "centimeters". I want to show a dropdown if "feet-inch" is selected, or else a textfield if "centimeters"is selected using ajax.
Am being able to show the textfield and a single dropdown successfully with ajax call triggered from the selection of the radio buttons, But I need to have two dropdowns, one to select "feet" and another to select "inches" right..?
So my problem is that am not being able to show two dropdowns with one single ajax call. How can I achieve it...?? Or in other words, how can I replace two separate divs (both containing a dropdown select) with one single ajax call..?
Alseo do let me know, if there are any other better ways to achieve this kind of height selection form..?
Please provide, codes for both form elements and the ajax call if possible. (am not an expert, you see..:p)
Thanks in advance.
Comments
I hope I understand
I hope I understand you.
Wrappers is the key. You can wrap any number of form elements of even a whole form in a custom wrapper div.
The ID of this wrapper can be used for replacement in the form API. like:
Thing you have to take care of is providing a callback function that returns only these fields.
This way you can replace multiple fields at once, or even a whole form.
If you cant wrap these fields in 1 div, EG if there are other htlm elements in between that must not be replaced, than the ajax forms api falls short AFAIK. Build your own js then, like you used to in D6.
Regards,
Kees
I understand that I have to
I understand that I have to wrap these two fields inside a single wrpper. But how can I return two form elements from a single callback function.....?
Worked only once..! but still facing some problem.
Hey.. Thank you so much...:) Thanks for the idea... But am still facing some problem, n I dont know what it is..!
I put both select fields inside a fieldset and wrapped that fieldset with the wrapper to be replaced. and put it inside the something_form() function with an if statement. It did worked for me once, but next, whne I refreshed it, its not working..! I tried a lot, I cant see any problem with the code but still no luck... Below is my code, please show me wats wrong....
below is the code of the callback function,
?>