script language="JavaScript" type="text/JavaScript">
<!--
function preview() { //v3.0
document.Newtheme.action="preview.asp";document.Newtheme.target="_blank";}
function formok() { //v3.0
document.Newtheme.action="";document.Newtheme.target="_self";}
//-->
</script>
<form name="Newtheme" method="post" action="">
<input type="submit" name="Submit" value="发表新主题" onclick="formok()">
<input type="submit" name="Submit" value="预览新主题" onClick="preview()">
</form>
<!--
function preview() { //v3.0
document.Newtheme.action="preview.asp";document.Newtheme.target="_blank";}
function formok() { //v3.0
document.Newtheme.action="";document.Newtheme.target="_self";}
//-->
</script>
<form name="Newtheme" method="post" action="">
<input type="submit" name="Submit" value="发表新主题" onclick="formok()">
<input type="submit" name="Submit" value="预览新主题" onClick="preview()">
</form>
博客展示了使用JavaScript实现表单提交功能的代码。定义了preview和formok两个函数,分别用于预览新主题和发表新主题,通过修改表单的action和target属性来控制提交行为,并在表单的提交按钮上绑定相应函数。

2万+

被折叠的 条评论
为什么被折叠?



