lbh2011 Posted January 27, 2012 Share Posted January 27, 2012 Hey everyone, I am looking to create an advanced contact form but need someone to point me in the right direction. I need to create a customer service form and would like it to contain the usual fields e.g. Name, Email etc. but also want to include a drop down field which has a couple of options e.g. Sales Enquiry, Order Status etc. Once one of those options has been selected e.g. Order Status, I then want a further section of the form to appear where the user can input data such as their order number, order date etc. Does anyone have any ideas on how to achieve this or know of any demos/scripts which they think might help. Quote Link to comment Share on other sites More sharing options...
Drongo_III Posted January 27, 2012 Share Posted January 27, 2012 This is really more client side to be honest. You just need some jquery and some logic within your jquery. specifically you'll use the .change() function to register when a new selection has been made (i.e. from your drop down) and this would fire off the code for the new piece of the form you want to display. This should point you in the right direction - http://api.jquery.com/change/ You could of course load the form elements using ajax but i cant exactly see why it would be worth sapping server resources for soemthing that can be done client side Hey everyone, I am looking to create an advanced contact form but need someone to point me in the right direction. I need to create a customer service form and would like it to contain the usual fields e.g. Name, Email etc. but also want to include a drop down field which has a couple of options e.g. Sales Enquiry, Order Status etc. Once one of those options has been selected e.g. Order Status, I then want a further section of the form to appear where the user can input data such as their order number, order date etc. Does anyone have any ideas on how to achieve this or know of any demos/scripts which they think might help. Quote Link to comment Share on other sites More sharing options...
lbh2011 Posted January 27, 2012 Author Share Posted January 27, 2012 Great, thanks. I shall take a look at a client side approach. Quote Link to comment Share on other sites More sharing options...
Drongo_III Posted January 27, 2012 Share Posted January 27, 2012 If you need any more help just yell! Great, thanks. I shall take a look at a client side approach. Quote Link to comment Share on other sites More sharing options...
Adam Posted January 27, 2012 Share Posted January 27, 2012 Just be sure to display the additional fields by default, so that if a user without JS support comes along they can still complete it. Hide them as the page is loaded with JS. Quote Link to comment Share on other sites More sharing options...
lbh2011 Posted January 27, 2012 Author Share Posted January 27, 2012 Good point Adam. I think it's going to be best to validate the form server side based on the option selected by the user, which in turn reveals that section of the form. Thanks! Quote Link to comment Share on other sites More sharing options...
lbh2011 Posted January 27, 2012 Author Share Posted January 27, 2012 Almost finished the front end, just need to add some validation now! I found a good script to show/hide content based on the selection of a drop down field - it may help someone! http://anthonygthomas.com/2010/03/14/display-form-fields-based-on-selection-using-jquery/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.