By karthikkumarbodu on
Hi,
I want to get the list of counties in a select box depending upon the selection of state in states select box. I am trying to get this done using AJAX and Jquery, i am able to get the list of counties depending on the selection of state but when i am trying to submit these values into the hook_submit i am unable to send that and i am left with an error on the screen saying that :
"PLEASE CONTACT THE SITE ADMINISTRATOR".
Can any one help me to get this problem solved ?
Thanks,
Karthik
Comments
The addresses module already
The addresses module already does this.
That is all that it says?
That is all that it says? That is a not very clear error. It probably says illegal value too. What is probably happening is that you are using an empty form dropdown for the counties, and when it is populated by jquery, it is being filled with values that are not defined in your hook_form definition of this drop down. when you submit that form, drupal form module will not recognize the value and give you that error. You need to do something like this http://groups.drupal.org/node/1839 and implement your own validation. Make sure you know what you are doing.
Divide the task into 2 forms
Hi,
Papile is correct. If you change the values in a select list, submit the form, Drupal will throw an illegal value error.
You can re-architect and divide the task into 2 forms. You have a parent form (select states) that asynchronously calls to the server (uses Ajax), then repaints the child form (select countries).
The parent form contains a an html "div" area that gets painted when your client side Jquery ajax handler gets the server response.
Since your country select list is now populated at the server, you won't get a illegal value error. You are always posting the same form the server created (i.e. the form gets created at the server but is repainted asynchronously).
I believe that should perform the task at hand.
I have a similar example here:
http://public-action.org/content/-my-profile-dynamic-ajax-form-processing
That example paints a child form with some different elements ( a simple fieldset, textfield, submit and cancel buttons). However, you could take the example and replace the bottom form with you "country select list".
Hope that helps.
Thanks,
Can any one suggest any solutions to work this out?
Karthik Kumar Bodu
drupal ahah u can use here
http://drupal.org/node/348475,
User ahah helper module (http://drupal.org/project/ahah_helper) to make this simple.
Rajan