I have the following html:
<body>
<form action="site1">
<input type="image" name="submit" border="0" src="images/front/search_travel.png" alt="" onclick="provider_popup();"/>
</form>
<form name="frmRight1" action="site2" target="_blank" >
<input type="hidden" name="sector_id" id="sector_id" value="90" />
<input type="submit" style="visibility:hidden;" />
</form>
<script type="text/javascript">
function provider_popup (){
document.frmRight1.submit();
return false;
}
</script>
</body>
And while I submit the button with name submit
, I get one another tab and it will load 'site2'
But this process is not working in chrome.
Let me know the reason
Okay, you also needed to prevent the image button from submitting its form. Your function returned false, but you need to return that to the onclick, hence the problem. Do it like this:
onclick="return provider_popup();"
I recommend you ditch the <input type="image">
approach anyway, and use a pure element with an onclick
attribute. Makes your HTML much simpler i.e.
<body>
<img src="images/front/search_travel.png" alt="Submit" onclick="provider_popup();" />
<form name="frmRight1" action="site2" target="_blank" >
<input type="hidden" name="sector_id" id="sector_id" value="90" />
<input type="submit" style="visibility:hidden;" />
</form>
<script type="text/javascript">
function provider_popup () {
document.forms['frmRight1'].submit();
}
</script>
</body>
Another alternative is to wrap the image in an anchor <a href...
and apply the onclick
to that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With