Is there way to or it is possible to do it using javascript/jQuery?
Based Link URL: first one will check Type A and Type B and second example will check Type D
?type=A&type=C or ?type=D
My current form:
<form name="input" action="" method="post" ><br />
Select Type: <br />
<input type="checkbox" name = "type" value="A" /> A <br />
<input type="checkbox" name = "type" value="B" /> B <br />
<input type="checkbox" name = "type" value="C" /> C <br />
<input type="checkbox" name = "type" value="D" /> D <br /> <br />
<input type="submit" value="Submit" />
Any tips and advised to do it?
Do it like this:
Explanation:
Consider the url is ‘
http://sample.com?type=A&type=C‘. Then:iis the index of ‘?‘ sign in that url.substr() will cut
type=A&type=Cpart from the url. After the cut, we will have this string:.replace() removes “type=” parts from the above mentioned string:
.split() splits that string into array:
$.inArray() checks whether value of current
checkboxis in the["A","C"]array. If it is, thenchecks(.prop('checked',true)) thecheckbox.