homepage Welcome to WebmasterWorld Guest from 54.227.11.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
href="#"
Help!
PeteM




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

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

 

Fotiman




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

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.

PeteM




msg:3708789
 9:21 pm on Jul 27, 2008 (gmt 0)

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

Cheers, Pete

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved