The example in this article describes the method of JS controlling form submission. Share it with everyone for your reference. The details are as follows:
<Script Language="JavaScript"> function autoSubmit(){ var form = document.forms[0]; var actionPath = "?mo=phone"; form.action = actionPath; form.submit(); return true; } </Script>
If you need two submit buttons, the attribute value of type="" is "submit" and the other is "button", that is, one is submitted by the button itself, and the other is submitted by JS control
<form method="post" name="form1" id="form1" action="?mo=phone&do=opreat" > <input type="hidden" value="" name="phoneid" id="phoneid"> <table border="0px" style="font-size:12px" width="630px" > <tr> <td align="right">手机型号:</td> <td><input type="text" id="phonetype" name="phonetype" style="width:120px" <?# if $pinfo.pass_var.phonetype ?>value="<?# $pinfo.pass_var.phonetype ?>" <?# /if ?> /></td> <td><div id="phonetypeTip" style="width:250px"></div></td> </tr> <tr> <td align="right">类型:</td> <td><select name="type" id="type"> <?# foreach from=$types item=value ?> <option value="<?# $value.type ?>" <?# if $pinfo.pass_var.type== $value.type ?>selected="selected"<?# /if ?>><?# $value.type ?> </option> <?# /foreach ?> </select></td> <td><div id="typeTip" style="width:250px"></div></td> </tr> <tr> <td align="right">厂商:</td> <td><select name="brandid" id="brandid"> <?# foreach from=$brand item=value ?><option value="<?# $value.brandid ?>" <?# if $pinfo.pass_var.brandid== $value.brandid ?>selected="selected"<?# /if ?> ><?# $value.name_zh ?></option><?# /foreach ?> </select></td> <td><div id="brandidTip" style="width:250px"></div></td> </tr> </table> <input type="submit" value="增加手机" > <input type="button" onclick="autoSubmit();" value="搜索手机" > </form>
I hope this article will be helpful to everyone’s JavaScript programming design.