September 11, 201214 yr Guy's. more help is needed on my site. I'm sure there is probably the answer already on here and is almost certainly on Google but I am having no joy in finding it or the examples I have found don't explain the specifics enough and are a little confusing. I have this contact form on this site http://www.uksecurity-directory.co.uk/addyourcompany.html The from works perfectly well and I get all the information but clients are getting a little confused when selecting regions. They should be selecting either UK Wide OR selecting individual regions but I'm getting people selecting almost everything. What I'm trying to achieve is making it so that if you select UK Wide, the rest of the region check boxes are greyed out/ un-selectable. But if they don't select UK Wide they still need to be able to select multiple regions. Am I right in thinking this needs to be done in JS? I also want the text box lower down the page to only be available to type in if Silver is selected from the radio buttons. As with all my previous requests for help, I'm not expecting someone to just do the work for me, although it would be handy , but if you know of a good place to learn this type of coding, It would be appreciated. As always, I thank you for your time.
September 11, 201214 yr You're definitely going to need JS to get the effect you want for the checkboxes and also to make the single text box editable for certain values. It's worth noting that you are going to need to validate it regardless once the form is submitted, as JScan be bypassed/disabled pretty easily and while a majority of people do use JS, not all do. As for where to learn - I see you're using jQuery which is a great library and the one I use for everything. I'd recommend using this site http://www.learningjquery.com/ or getting the sitepoint jQuery novice to ninja eBook
September 11, 201214 yr Author You're definitely going to need JS to get the effect you want for the checkboxes and also to make the single text box editable for certain values. It's worth noting that you are going to need to validate it regardless once the form is submitted, as JScan be bypassed/disabled pretty easily and while a majority of people do use JS, not all do. As for where to learn - I see you're using jQuery which is a great library and the one I use for everything. I'd recommend using this site http://www.learningjquery.com/ or getting the sitepoint jQuery novice to ninja eBook Thanks for your speedy reply. I shall give it a go.
September 19, 201214 yr Author Well I got the desired effect I wanted and thanks to some hints over at stackoverflow and the tutorials that Jay linked. This is what I used. I added the following into my Javascript coding that I already had in place for the validation. $(document).ready(function() { $('.listing').change(function(){ if ($(this).val() == 'Bronze') { $('#Description').attr('readonly','readonly'); } else { $('#Description').removeAttr('readonly'); } }); }); This didn't exactly work at first because my Bronze radio button is set to be the default with the attribute checked. What was happening was that when the page opened Bronze is selected by default but I was still able to input into the text box, unless I selected Silver, then re-selected Bronze again. I added the attribute readonly="readonly" to the text box and this has made it read only to start with until Silver is selected. All works perfectly!!
Create an account or sign in to comment