Welcome to WebmasterWorld Guest from 23.22.79.235

Forum Moderators: open

Message Too Old, No Replies

href="#"

Help!

   
5:44 pm on Jul 27, 2008 (gmt 0)

10+ Year Member



Something strange is happening with my form. When viewing the page Iwas expecting the link to be set to '#' but for some reason the url is now being prefixed with the page's own url.


<form name="myform" method="post" action="/index.php">
<input type="hidden" name="freq" value="">
<a class="green" href="#" onClick="document.myform.freq.value='abc';submitform()">click here</a>
<a class="green" href="#" onClick="document.myform.freq.value='def';submitform()">click here</a>
<input name="checkbox" value="ticked" type="checkbox">
</form>
<script language="JavaScript">
function submitform()
{
document.myform.submit();
}
</script>

Can anyone help?

Cheers, Pete

8:42 pm on Jul 27, 2008 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Your form's submit action is "/index.php"
Your links are submitting the form. It doesn't matter what the href value is of the link because you're going to be redirected to "/index.php" no matter what.
9:21 pm on Jul 27, 2008 (gmt 0)

10+ Year Member



Ah gotcha. Sorry for that, managed to confuse myself.

Cheers, Pete