PDA

Click to See Complete Forum and Search --> : Works with BUTTON not with IMAGE


turfbult
Jan 29th, 2001, 02:29 AM
Hello,

Please check this code and see if you know why it does not work!! I used to use a submit BUTTON, but I now just want to use an image. I tried putting the image "on top" of the button, but then it does not show in Netscape!!


<form name="frmprov" id="frmprov" method="POST" action="city.asp"
onSubmit="frmTest.thehidden.value=frmTest.theselect.value">
<input type="hidden" name="lstcountry" value="<%=Request.Form("lstcountry")%>"><dl>
<dd align="center"><div align="center"><center><p><select name="lstprovince"
id="lstprovince" size="1">
<%if varcountry <> "USA " then%> <option selected value "ALL">ALL</option>
<%end if%>


</select><input src="images/submit.gif" name="Submit" width="74" height="18" type="image"
onclick="redirectpage()" border="0"> </p>
</center></div></dd>


Sorry this did not come out as it should. Maybe someone can also tell me what to do if I want to submit CODE: on this forum!!??

There is some ASP code between all of this which populates a dropdown - I did not post this however!!

Hopefully you can make out what I'm trying to do. I used to use a BUTTON as the input type and it worked fine, now I want to use an image (like above) and I then get the error "frmTest is undefined".

It must have something to do with the "onsubmit" in my form section. The button "submits", but not the image!!

Thanks
T

Ianpbaker
Jan 29th, 2001, 03:15 AM
Hi turfbult

you can use a href instead of trying to put an image in a submit button (which i think is not supported by NS)

Use the following

<a href="javascript:document.frmprov.submit();"><img src="images/submit.gif" border="0"></a>

This will work in both IE and and NS

Hope it helps

Ian

turfbult
Jan 29th, 2001, 03:23 AM
Thanks Ian,

Works like a charm!!!

T

turfbult
Jan 29th, 2001, 03:40 AM
Ian,

Maybe I talked to fast!!??

When the image/button is clicked it MUST run the redirectpage script. Because, depending on what was chosen in the dropdown one of 2 pages are loaded!!

In IE, it DOES - not in NS.

I've been battling with this since I started developing my site!!

T

Ianpbaker
Jan 29th, 2001, 03:44 AM
sorry turfbult, I miss read your post, I c where it's going wrong change to the following in the onsubmit

frmTest.thehidden.value=frmTest.theselect.options[frmTest.theselect.selectedIndex].value

This way of getting the value works in both :)

Ian

turfbult
Jan 29th, 2001, 03:59 AM
Ian,

This is how I did it - notice the onclick="redirectpage()">
This is what NS is "missing" (and it's only been happening since I changed from input type=button to input type=image)

<a href="javascript:document.frmprov.submit();"><img src="images/submit.gif"
border="0" onclick="redirectpage()">

The redirectpage function manages what page must be loaded - either city.asp or details.asp!!

IE = 100%. Netscape just loads city.asp everytime - even though it should load details.asp. So what I'm thinking is that NS ignores the script (redirectpage) for some reason.


This is what redirectpage looks like... (I think you still helped me with this a while ago - or Clunietp!!??)

<script language="javascript">

function redirectpage()
{
if(document.frmprov.lstprovince.options[document.frmprov.lstprovince.selectedIndex].value == 0)
{
document.frmprov.action = "details.asp";
document.frmprov.submit();
}
else
{
document.frmprov.submit();
}
}

</script>


T.

Ianpbaker
Jan 29th, 2001, 04:18 AM
in that case mate just replace the href to

<a href="javascript:redirectpage();">

and that will call the re-direct page instead

Ian

turfbult
Jan 29th, 2001, 05:15 AM
Ha-ha..... don't I feel like the idiot!! Thanks Ian.

When I see javascript I go totally blank..........

Thanks again, and sorry for the trouble.

T

Ianpbaker
Jan 29th, 2001, 05:19 AM
Don't worry about it mate, we learn by our mistakes :)

If you saw me a year ago, some of the stupid mistakes I was making ... well lets not go down that road ;).

Ian