
Originally Posted by
EricWatson
I've been doing this for 10 years and I would be hard pressed to edit the code of a pre built CMS.
Hello.
This CMS is structured to be "easily" customized; the form I want to modify in fact is part of a template (smarty).
So, no problem with code changing.
Anyways...
The "Original" code is something like this:
Code:
<form action="" id="zip" method="post">
<select class="field" name="set_zip_filter_distance" onchange="$('zip').submit()">
<option value="">Distance</option>
<option value="1">1km</option>
<option value="5">5km</option>
<option value="10">10km</option>
<option value="15">15km</option>
.....and so on.....
</select>
<input type="hidden" name="submit_zip_filter"/>
<!-- BUTTON1---<input type="submit" name="submit_zip_filter" value="submit" class="button" />
BUTTON2---<input type="submit" name="clear_zip_filter" value="reset" class="button" />-->
</form>
The parts in bold arethe ones I added.
At the bottom of it you will noticed 2 lines of code I commented out. They were 2 submit button I'm trying to get rid of, and that's the reason why I want to change the "name part" of the <input> line to change in accordance to the option selected.
The code above works but it only submits, I wanto to add 1 more option (<option value="RESET">RESET</option>) and cause the form to submit as if it was BUTTON2 if "RESET" is selected and like BUTTON1 if the other option are selected.
So far I tried
Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
if $('#set_zip_filter_distance').change(function(){
$('#submit_line').attr('name', 'clear_zip_filter');
this.form.submit();
}
else
{
this.form.submit();
});
</script>
...but it doesn't work
.
Maybe someone experienced can help me?
Thanks a lot.
mass
Bookmarks