Document.form.submit() 不起作用
Document.form.submit() not working
>我有以下内容:
<form action="file.php" method="post" enctype="multipart/form-data" name='form' id='form'>
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" style="BORDER-RIGHT: #fe03b4 1px solid; BORDER-TOP: #fe03b4 1px solid; BORDER-LEFT: #fe03b4 1px solid; BORDER-BOTTOM: #fe03b4 1px solid">
<tr>
<td style="margin-left: 3px">
<b><font color="#f803f8" size="1">Eyes</font></b>
</td>
<td>
<select size="1" name="eyes" class="input" id="eyes" style="BACKGROUND-COLOR: #f7ed79; COLOR: #000000; font-family: Arial; font-size: 10px; width:150px;">`
<option selected="selected" value="">Select</option>
<option value="1"<? if ($eyes=="1") echo "selected"; ?>>Blue</option>
<option value="2"<? if ($eyes=="2") echo "selected"; ?>>Green</option>
</select>
</td>
</tr>
</table>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" style="BORDER-RIGHT: #fe03b4 1px solid; BORDER-TOP: #fe03b4 1px solid; BORDER-LEFT: #fe03b4 1px solid; BORDER-BOTTOM: #fe03b4 1px solid">
<tr>
<td style="margin-left: 3px">
<b><font color="#f803f8" size="1">Description</font></b>
</td>
<td>
<textarea rows='5' name='description' cols='120'><? echo "$description"; ?></textarea>
</td>
</tr>
</table>
<br />
<table width="100%" border="0" align="center">
<tr>
<td align="center">
<input name='Update' type='submit' onClick="if(document.form.eyes.value == ''){ alert('Eyes Color?'); document.form.eyes.focus(); return false; } else
if(document.form.description.value==''){ alert('Description?'); document.form.description.focus(); return false; } else
{ document.form.submit(); parent.scrollTo(0,0); }" value='Update' style="width:100%; font-size:10px" />
</td>
</tr>
</table>
</form>
第一个警报(眼睛)有效,但第二个警报没有给我警报,即使没有插入文本,它也会保存。
数据库中的 EYES 列定义为 0,然后我可以选择选项 1 或 2 进行更新。
如果以前没有保存,是否可以更新数据库中的文本字段?换句话说,数据库中的文本列为 NULL(未保存文本),我尝试在没有保存的情况下进行更新。
这里有任何帮助吗?
这是因为,按钮的类型是提交。 如果要手动控制提交,请将其更改为按钮。或者改用表单提交事件,在提交事件中验证表单,如果表单无效,则取消提交。
http://msdn.microsoft.com/en-us/library/ie/ms536972(v=vs.85).aspx
相关文章:
- Document.form.submit() 不起作用
- jquery-submit函数不起作用
- using document.forms[“MbrForm”].submit();不起作用
- JQuery 对话框 / submit() 在 IE8 中不起作用
- 如果 ajax 刷新了绑定对象,则 .submit 不起作用
- jQuery .submit( [callback] ) 中的 .click 不起作用
- 角度 ng-submit 不起作用
- JavaScript submit() 后跟 self.close() 不起作用
- jquery-submit不起作用
- Ng-click和ng-submit不起作用
- 当函数被调用'submit'时,表单onSubmit不起作用
- $.submit()不起作用
- Javascript form.submit()在Firefox中不起作用
- AngularJS的ng-submit输入键不起作用
- Submit();不起作用
- jQuery .append在.submit上不起作用
- 在CakePHP中使用.submit()似乎不起作用
- .submit()函数在ajax()函数中不起作用
- form.submit()方法中的setTimeout不起作用
- 的形式.submit方法在jQuery中不起作用