<form method='GET' name='search' action='index.php'>
<input type="hidden" name="searchType" value="all" />
<input type="checkbox" name="vehicle" value="first"/>
<input type="checkbox" name="vehicle" value="second" checked/>
</form>
<a href="javascript:document.search.submit()"></a>
From the form above, I want the URL data to be index.php/searchType=all when first checkbox is checked and URL data to be index.php/ (to be empty) if second checkbox is checked. How am I going to do that? Is it possible to on or off the “hidden” parameter as the example above? I don’t want it to be index.php/searchType= when second checkbox is checked but to remove the whole parameter name.
This is second question:
I want to inject some parameters in the Form Action, how could I do that? Is it looked something like this:
<a href="javascript:injectParameter();document.search.submit()"></a>
What am I supposed to write in the injectParameter() method?
Sorry about I am quite new in Javascript and web.
I think, if you don’t want the input fields to show up in the URL, you can remove them from the form before posting.
Untested:
Is that your goal?
Also multiple fields with the same name doesn’t work this way.
you’ll maybe want to use radiobuttons like so:
or create an array of fields like so:
I hope this helps…