Jump to content

Creating a form that cascades to a new form when item is not found in database


jdgower

Recommended Posts

I am not sure if this is in the write forum, I apologize if it's not - I assume it could deal with php, html, ajax, mysql or probably all 4...

 

I am trying to create a form that is like this:

 

I have 3 mysql databases

  • progressive
  • statefarm
  • encompass

 

I want to create a form that asks first for something like "what kind of car do you drive?"...now let's say you select 'pontiac sunfire' from the drop down (which is populated by a master list of all models from every database) and I dont have a 'pontiac sunfire' listed under 'models' in the statefarm database...I would then like a dropdown to appear below saying that statefarm doesn't have that model listed, please select a model below and then have it give all the models on just the statefarm database.

 

Please point me in the right direction or even let me know if it's possible - would i instead have to create a page that the user goes to when they hit submit?

 

Thank you in advance,

Jeremy

Link to comment
Share on other sites

I do not understand. If it doesn't have the model for State Farm, then is it an option for the select? I'm really not sure what you're trying to do.

 

As far as making it appear or even adding it to the page/DOM (and even the MySQL database), of course you can. You might need jQuery LiveQuery, though, unless you want to make the select box hidden on the page.

 

It's really up to exactly how you want to do this. Generally, have jQuery, through AJAX, send the selected option as a parameter to the PHP page (maybe some kind of session token to prevent abuse here?), then have PHP check the MySQL. Use the callback to read the output from the php page.

 

If you want to make the select box's options dynamic, then you'll need to build it with PHP that checks the MySQL, put it through the callback, then add it to the DOM with jQuery. You will need LiveQuery if you do it that way.

 

Hope I helped!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.