How can I change the onSubmit
value dynamic or should I remove onSubmit
and have <action="return zomlink();">
What I want is to change the action/onsubmit
link to a new link depending on what option they select in the drop down box. I cannot use Jquery
i need it in plain javascript
form.
<form method="post" id="buyvipform" name="buyvipform" class="buyvipform" onSubmit="return zomlink();">
<select name="zomlink" id="zomlink" style="margin-top: 290px;">
<option value="1906083">3 days Trial (2€)</option>
<option value="1906104">31 days (19€)</option>
<option value="1906125">90 days (50€)</option>
<option value="1906146">365 days (99€)</option>
</select>
<input type="submit" value="" style="background:url(<?php bloginfo('template_directory'); ?>/images/vbestall.png) no-repeat; width: 106px; height: 40px; border: 0px;">
<input type="hidden" name="hide_credits" value="True">
</form>
Script:
function zomlink() {
if(document.zomlink.value == '1906104') {
document.buyvipform.action = 'http://google.com';
}
if(document.zomlink.value == '1906125') {
document.buyvipform.action = 'http://facebook.com';
}
return true;
}
Fiddle: http://jsfiddle.net/6x4u28yd/