Sunday, June 2, 2024
59
rated 0 times [  64] [ 5]  / answers: 1 / hits: 38977  / 13 Years ago, tue, july 19, 2011, 12:00:00

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


More From » google-chrome

 Answers
60

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.


[#91112] Monday, July 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lincolnx

Total Points: 602
Total Questions: 90
Total Answers: 94

Location: Saint Lucia
Member since Wed, Feb 8, 2023
1 Year ago
;