...

View Full Version : anything wrong with this script



xiaodao
12-24-2004, 12:17 PM
function gosubmit(address) {
var address;
document.myformname.action=address;
document.myformname.submit();
return true;
}
</script>

because i want to create something that can submit to different url address in same form using text links, am i correct this way?

Bobo
12-24-2004, 04:04 PM
I don't think your supposed to have "var address" and address as an arguement, so get rid of the "var address" line. Otherwise fine, I think.

xiaodao
12-25-2004, 02:53 AM
it is not working, strange, i dont know why please help

Bobo
12-25-2004, 04:44 AM
Let ~me see the code that executes the function and the code for the form itself.

xiaodao
12-25-2004, 07:35 AM
<script language="javascript">
function gosubmit(address) {
document.approvearticle.action=address;
document.approvearticle.submit();
return true;
}
</script>
<form name=approvearticle>
$sql=mysql_query("SELECT * FROM pa_article WHERE status=0");
while ($row=mysql_fetch_array($sql)) {
echo "<tr bgcolor=#f5f5f5 align=center><td><input type=\"hidden\" name=\"rowid\" value=\"".$row[id]."\"><input type=\"text\" name=\"title\" value=\"".$row['title']."\"></td><td><input type=text size=5 name=bookid value=".$row['bookid']."></td><td><input type=text name=chapterid size=5 value=".$row['chapterid']."></td>";
echo "<td><a href=\"javascript:gosubmit(approvearticle.php?action=update);\">update</a<a href=\"javascript:gosubmit(approvearticle.php?action=preview);\">preview</a>&nbsp;<a href=\"javascript:gosubmit(approvearticle.php?action=approve);\">approve</a></td></tr>";
}
?>
thanks

dumpfi
12-25-2004, 11:57 AM
This should work:

<script type="text/javascript">
function gosubmit(address) {
document.approvearticle.action=address;
document.approvearticle.submit();
return true;
}
</script>
<form name="approvearticle">
<table>
$sql = mysql_query('SELECT `id`, `title`, `bookid`, `chapterid` FROM `pa_article` WHERE `status` = 0');
while ($row = mysql_fetch_assoc($sql)) {
echo '<tr style="background-color:#f5f5f5" align="center"><td><input type="hidden" name="rowid" value="'.$row['id'].'"><input type="text" name="title" value="'.$row['title'].'"></td><td><input type="text" size="5" name="bookid" value="'.$row['bookid'].'"></td><td><input type="text" name="chapterid" size="5" value="'.$row['chapterid'].'"></td>';
echo '<td><a href="javascript:gosubmit(\'approvearticle.php?action=update\');">update</a><a href="javascript:gosubmit(\'approvearticle.php?action=preview\');">preview</a>&nbsp;<a href="javascript:gosubmit(\'approvearticle.php?action=approve\');">approve</a></td></tr>';
}
?>
</table>
</form>
dumpfi

xiaodao
12-25-2004, 12:30 PM
thanks, problem solved



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum