...

View Full Version : Multiple Function Href



mitch@vif
05-07-2007, 01:40 PM
I would like to do multiple functions on one onclick, then go to a new page.
Here is my attempt using one function to do two things. Suggestions please

<SCRIPT language="JavaScript">
function submitform()
{
document.form.submit();
default_b.php?action=add_item&id=<?php echo $row["id"]; ?>&qty=1">
}
</SCRIPT>
</head>

<body>
<form name="form" action="">
<input type='checkbox' name='chk'>

</form>
<A href="#" onClick=" submitform();return false;">Add Item</A>

cyberlogi
05-08-2007, 08:33 AM
I'm not really sure what the question is. I'll tell you what your code does though. When you click the anchor, it will go to your function and submit the form, which will POST to the current page. Never executing this mysterious line


default_b.php?action=add_item&id=<?php echo $row["id"]; ?>&qty=1">

I assume this is some kind of link you want to forward the browser to. As it is written, you'll need to use AJAX to save the form, instead (plenty of online tutorials available for AJAX) and window.location = "your uri"; after the AJAX call.

However, it would be much simpler, if you use PHP code wherever you process the form submission, to forward to the next page instead.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum