Hi; i have 2 problems : 1. i have a problem with checkbox. I want when i onclick to checkbox i want to submit form. i use this codes : $('#myform label').click(function() { $('#myform').submit(); }); it's working but i cannot get this checkbox values 2. Question When i submit my form adress bar will be like this : search.asp?cartype%5B%5D=Cars&cartype%5B%5D=SUV&fuel%5B%5D=Diesel&fuel%5B%5D=Gas is it possible to use like this : search.asp?cartype=Cars,SUV&fuel=Diesel,Gas,Hybrid My codes : <script> $('#myform label').click(function() { $('#myform').submit(); }); </script> <style> <!-- label {background: url(images/splitter.png) no-repeat -260px -47px;display:block;height:20px;float:left;width:20px;margin:13px 0 0 10px;padding-left:30px;display: block;line-height: 45px;} label:hover, label.active{background:url(images/splitter.png) no-repeat -260px -67px;} li{height:24px;display:block} --> </style> <form id="myform" action="search.asp" enctype="multipart/form-data" method="get"> <ul> <li><input type="checkbox" name="cartype[]" value="Cars" style="display:none" id="cars1" /><label for="cars1" class="active">Cars</label></li> <li><input type="checkbox" name="cartype[]" value="SUV" style="display:none" id="cars2" /><label for="cars2">SUV</label></li> <li><input type="checkbox" name="cartype[]" value="Minivan" style="display:none" id="cars3" /><label for="cars3" >Minivan</label></li> </ul> <ul> <li><input type="checkbox" name="fuel[]" value="Diesel" style="display:none" id="fuel1" /><label for="fuel1" class="active">Diesel</label></li> <li><input type="checkbox" name="fuel[]" value="Gas" style="display:none" id="fuel2" /><label for="fuel2" class="active">Gas</label></li> <li><input type="checkbox" name="fuel[]" value="LPG" style="display:none" id="fuel3" /><label for="fuel3" class="active">LPG</label></li> <li><input type="checkbox" name="fuel[]" value="Hybrid" style="display:none" id="fuel4" /><label for="fuel4" class="active">Hybrid</label></li> </ul> </form>
i solve my first problem; $('#myform input').change(function() { $('#myform').submit(); }); but still i cannot solve the second one anybody help?
You would need to use mod_rewrite which is an Apache module to change the URLs like tha: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
I wouldn't make them checkboxes at all - I'd make them SUBMITS... since that seems to be what you want them to do; that way you don't need any of that jQuery BS pissing all over your site. You're markup is confusing nonsense... it is very rare a list would be appropriate inside a table, since those seem more to be two fieldsets. Since they're all set to none I'm not sure how any of them would get chosen unless you've got some other scripttardery in there we're not seeing, and with so many of them having the same name it's not like they're going to report values properly. Also makes no sense whatsoever to have the scripting attached to the labels instead of the inputs... That could be your problem right there... I mean with that code you could never select vehicle type and fuel type at the same time, usually why submit is an entirely separate button... If anything, this looks more like a job for a separate submit and radio buttons instead of checkboxes! I'm guessing wildly, but I suspect this: <form id="myform" action="search.asp" enctype="multipart/form-data" method="get"> <fieldset id="vehicleType"> <legend>Vehicle Type</legend> <input type="radio" name="carType" value="Cars" id="cars1" /> <label for="cars1">Cars</label> <br /> <input type="radio" name="carType" value="SUV" id="cars2" /> <label for="cars2">SUV</label> <br /> <input type="radio" name="carType" value="Minivan" id="cars3" /> <label for="cars3" >Minivan</label> </fieldset> <fieldset id="fuelType"> <legend>Fuel Type</legend> <input type="radio" name="fuel" value="Diesel" id="fuel1" /> <label for="fuel1">Diesel</label> <br /> <input type="radio" name="fuel" value="Gas" id="fuel2" /> <label for="fuel2">Gas</label> <br /> <input type="radio" name="fuel" value="LPG" id="fuel3" /> <label for="fuel3">LPG</label> <br /> <input type="radio" name="fuel" value="Hybrid" id="fuel4" /> <label for="fuel4">Hybrid</label> </fieldset> <div class="submitsAndHiddens"> <input type="submit" value="Go" /> <!-- .submitsAndHiddens --></div> </form> Code (markup): Without any scripting is what you are TRYING to do -- since it makes no sense to submit if all they've done is check one or the other set of fields... Don't use javascript to take something simple (a form) and make it a non-semantic inaccessible mess. If that's doing what I think you are trying to do, there's NO reason to even have scripting on it. ** side note ** it is refreshing to at least see someone trying to use labels and ID's properly, you just need to drag it kicking and screaming the rest of the way into properly formed markup.