...

View Full Version : <RESOLVED>Why can't I submit?



Pembar
06-24-2009, 10:37 PM
<RESOLVED>

Hey guys,

I'm trying to use javascript to submit a form. I was wondering whether this was possible.



<html>
<head>
<script language='JavaScript'>
function submitURL(url) {
document.mForm.url.value = url;
document.mForm.submit();
}</script>

<form action="test12.php" method="post" name = "mForm" id = 'mIDForm'>
URL: <input type="text" name="url" />
</form> <P>

<A HREF=""
onClick="submitURL('http://www.google.com')";>Google</A>

</body>
</html>


Clicking on the link puts the correct URL in the input field, but then the page refreshes and nothing gets sent to test12.php.

Anyone have any clue?

Thanks much.

<RESOLVED>

Thanks a lot

tomws
06-24-2009, 10:49 PM
The page "refreshes" because of the anchor tag with the empty href - that means go back to self. If you don't want to follow that link, try using a "return false;" along with the function call.

Not sure if that will work for anchors, but that's how to break the submit for a button.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum