Forum Moderators: open

Message Too Old, No Replies

Can you combine 2 actions in an onlick event?

         

macz_g

7:28 pm on Jan 9, 2008 (gmt 0)

10+ Year Member



For a travel site I have a search widget and the site is supported with PPC.

The agency we are working with requests that we add a 1x1px gif that is only displayed when the "search" button is clicked.

Is it possible to combine the code to search and also display the img tag as part of the onclick event?

Current onlick code
<INPUT type="image" src="/images/css/find-hotel.gif" name="SearchWiz" value="Find A Hotel" title="Find A Hotel" border="0" onclick="javascript:document.HotForm.submit(); "/>

Image tracking tag
<img height="1" width="1" src="www.example.gif"/>

Any help is appreciated

Fotiman

9:03 pm on Jan 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It sounds like you're looking for a tracking image. Perhaps something like this:

<INPUT type="image" src="/images/css/find-hotel.gif" name="SearchWiz" value="Find A Hotel" title="Find A Hotel" border="0" onclick="function(){
var img = new Image();
img.src = "www.example.gif";
document.HotForm.submit();
}
"/>

[edited by: Fotiman at 9:04 pm (utc) on Jan. 9, 2008]

macz_g

10:12 pm on Jan 9, 2008 (gmt 0)

10+ Year Member



Yes, at the same time as the submit button is hit the script should make a call to the image and process the user request.

Thanks for your help, I'll test this out right now.

Dabrowski

6:36 pm on Jan 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In this case, couldn't you use an onSubmit on the form instead?

Fotiman

7:28 pm on Jan 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yeah, Dabrowski is right. There's no need for the onclick handler for type image to call form.submit() because that's going to happen anyway.

macz_g

6:00 pm on Jan 22, 2008 (gmt 0)

10+ Year Member



I have tried to code this, adding the display image to the submit instead of the onlclick but it's still not working.

Below is what I am working with:

<FORM NAME=HotForm ACTION="http://example.com/form.asp" METHOD=get>
<INPUT name=eapid type=hidden value="22436-30021">
<INPUT TYPE=HIDDEN NAME=GOTO VALUE="HOTSEARCH">
<INPUT TYPE=hidden NAME=rfrr VALUE="-34980">
<INPUT TYPE=hidden NAME=olid VALUE="">
<INPUT TYPE=hidden NAME=mdpcid VALUE="22436-30021.0.1">
</FORM>

<SCRIPT language=”JavaScript”>
<!--
function submitForm() {
http://example.tracking-image
// submit
document.HotForm.submit():
}
-->
</SCRIPT>

If possible could you point me in the right direction or to search phrase for a tutorial that would help?

Thanks

Fotiman

6:33 pm on Jan 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




<form name="HotForm" action="http://example.com/form.asp" method="get"
onsubmit="function(){var img=new Image();img.src="example.gif";}"
>
<input name="eapid" type="hidden" value="22436-30021">
<input type="hidden" name="goto" value="HOTSEARCH">
<input type="hidden" name="rfrr" value="-34980">
<input type="hidden" name="olid" value="">
<input type="hidden" name="mdpcid" value="22436-30021.0.1">
<input type="image" src="/images/css/find-hotel.gif" name="SearchWiz" value="Find A Hotel" title="Find A Hotel" border="0">
</form>