<input type="button" name="button" id="button" onclick="this.form.submit();" >
我想在onclick中判断一下,当 document.getElementById('testTab11').getElementsByTagName('input').length 大于1时,才执行 this.form.submit(); 否则 提示一下,但一直说语法错误,求助啊~~~一直不擅长JS ,另外分不多了T_T
我想在onclick中判断一下,当 document.getElementById('testTab11').getElementsByTagName('input').length 大于1时,才执行 this.form.submit(); 否则 提示一下,但一直说语法错误,求助啊~~~一直不擅长JS ,另外分不多了T_T
解决方案 »
- 复选框产生列表的问题??
- 网页中的文件连接,点右键另存为的时候,可否把另存为的文件名指定一个固定的名字?
- ****TD里有个input,如何获取这个INPUT? 在线等 *****
- 如果连续运行无数个javascript,其中一个有错误,能否不弹出alert的警告窗口呢?
- 按下方向键要停一下才能移动,能否不停顿呢?(内附源码)
- 关于飘动的窗口如何处理?急!!
- 向高手请教!!alert()
- 如何捕获到<area>对象的右键事件?
- javascript能否实现清屏效果!
- VBSCRIPT中的chr()/asc()函数在JAVASCRIPT中有吗?
- 求一匹配空值或11位数字的正则!
- JS要怎样控制同一事件触发的多个方法的先后顺序
<script>
function chkdata()
{
if (document.getElementById('testTab11').getElementsByTagName('input').length<=1)
{
alert("请输入");
return false;
}
esle
{
return true;
}
}
</script>
<form id="form1" name="form1" action="xx.php" onsubmit="return checkForm();"> 添加了吗 ?报什么错 。
<script>
function chkdata()
{
if (document.getElementById('testTab11').getElementsByTagName('input').length<=1)
{
alert("请输入");
return false;
}
else
{
this.form.submit();
}
}
</script>ls的笔误了。
else写成esle了。。
<form name="form1" id="form1" action="attractions_DIY_num3.php" method="post" onSubmit="return false;">
<div class="onLine_DIYLine_2Right">
<div class="onLine_DIYLine_2RightTopText">
<input type="hidden" value="<?php echo $adult;?>" name="adult" id="adult" onKeyUp="this.value=this.value.replace(/\D/g,'')"/>
<input type="hidden" name="children" id="children" maxlength="3" onKeyUp="this.value=this.value.replace(/\D/g,'')" value="<?php echo $children;?>"/>
<input type="hidden" name="days" id="days" maxlength="3" onKeyUp="this.value=this.value.replace(/\D/g,'')" value="<?php echo $num;?>"/>
<input type="hidden" name="title" id="title" maxlength="3" value="<?php echo $title;?>"/>
<?php if($type==1){ ?>
<input type="hidden" name="type" id="type" maxlength="3" value="1"/>
<?php }?>
</div> <?php
for($n=1;$n<=$num;$n++)
{
if($n==1){
?>
<div id="con_one_1">
<?php }else{?>
<div id="con_one_<?php echo $n;?>" style="display:none">
<?php }?> <div class="clear">
<div><span class="FB FZ14">第<?php echo $n;?>上午</span>(9:00-12:00)</div> <div class="DIYLine_2RightChangeBox"> <?php
if($type == 1){
$sql = "select * from dede_trip_son where mtid =".$id." and numhowlong = ".$n;
$rs = $mysql->query($sql);
}
?>
<table id="testTab1<?php echo $n;?>" name="testTab1<?php echo $n;?>" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="65%" height="25" align="center"><strong>景点名称</strong></td>
<td width="20%" height="25" align="center"><strong>交通方式</strong></td>
<td width="15%" height="25" align="center"></td>
</tr>
<?php
if($type == 1){
while($row = $mysql->fetch_array($rs)){
$morningnum = substr_count($row["morningtrip"],",")+1;
$morningtrip = explode(",",$row["morningtrip"]);
$tid = 19;
for($m=0;$m<$morningnum;$m++){
?>
<tr id="str<?php echo $n;?><?php echo $tid;?>" align="center">
<td width="65%" height="25" align="center"><input name= s_attractions<?php echo $n.$tid;?> type="text" readonly id= s_attractions<?php echo $n.$tid;?> value="<?php echo $morningtrip[$m];?>" /></td>
<td width="20%" height="25" align="center"><select name= s_traffic<?php echo $n.$tid;?> id= s_traffic<?php echo $tid;?> ><option value='其它'>其它</option><option value='自驾'>自驾</option><option value='公交'>公交</option><option value='自行车'>自行车</option></select></td>
<td width="15%" height="25" align="center"><button onclick="moveTr('<?php echo $tid;?>','<?php echo $n;?>','1');" >移除</button></td>
</tr>
<?php $tid++;}} } ?>
</table>
<center>
<input name="button" type="button" value="添加景点" class="DIYLine_2RightChangeBoxBotton" onclick="addTr(<?php echo $n;?>,1);"/>
</center>
</div>
</div>
<div></div>
<div class="clear">
<div><span class="FB FZ14">第<?php echo $n;?>下午</span>(12:00-18:00)</div> <div class="DIYLine_2RightChangeBox">
<table id="testTab2<?php echo $n;?>" name="testTab2<?php echo $n;?>" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="65%" height="25" align="center"><strong>景点名称</strong></td>
<td width="20%" height="25" align="center"><strong>交通方式</strong></td>
<td width="15%" height="25" align="center"></td>
</tr>
<?php
if($type == 1){
$sql_f = "select * from dede_trip_son where mtid =".$id." and numhowlong = ".$n;
$rs_f = $mysql->query($sql_f);
while($row_x = $mysql->fetch_array($rs_f)){
$afternoonnum = substr_count($row_x["afternoontrip"],",")+1;
$afternoontrip = explode(",",$row_x["afternoontrip"]);
$tid = 19;
if(!empty($row_x["afternoontrip"])){
for($f=0;$f<$afternoonnum;$f++){
?>
<tr id="xtr<?php echo $n;?><?php echo $tid;?>" align="center">
<td width="65%" height="25" align="center"><input name= x_attractions<?php echo $n.$tid;?> type="text" readonly id= x_attractions<?php echo $n.$tid;?> value="<?php echo $afternoontrip[$f];?>" /></td>
<td width="20%" height="25" align="center"><select name= x_traffic<?php echo $n.$tid;?> id= x_traffic<?php echo $tid;?> ><option value='其它'>其它</option><option value='自驾'>自驾</option><option value='公交'>公交</option><option value='自行车'>自行车</option></select></td>
<td width="15%" height="25" align="center"><button onclick="moveTr('<?php echo $tid;?>','<?php echo $n;?>','2');" >移除</button></td>
</tr>
<?php $tid++;}}} } ?>
</table>
<center>
<!--<button onclick="addTr(<?php echo $n;?>,2);" style="width:85px;height:25px; background:#333; font-weight:bold;" >添加景点</button>-->
<input name="button" type="button" value="添加景点" class="DIYLine_2RightChangeBoxBotton" onclick="addTr(<?php echo $n;?>,2);"/>
</center>
</div> </div>
<div class="clear">
<div><span class="FB FZ14">晚上</span></div>
<div>
<ul>
<li> 请选择酒店 <select style="width:150px;" name="select<?php echo $n;?>" id="select<?php echo $n;?>">
<option>无</option>
<?php
$rs=$mysql->query("select * from dede_archives where typeid = 40 ");
while($row = $mysql->fetch_array($rs))
{ ?>
<option><?php echo $row["title"];?></option>
<?php }?>
</select>
</li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<?php }?>
<div class="onLine_DIYLine_2Button">
<input name="Submit2" type="button" class="onLine_DIYLine_2Button_2" onFocus="blur()" onClick="javascript:history.go(-1)" />
</div>
<div class="onLine_DIYLine_2Button">
<input type="button" name="button" id="button" class="onLine_DIYLine_2Button_1"onclick="this.form.submit();" >
</div>
</div>
</div>
</form>
addTr() 是一个控制弹出子窗口的JS函数,在子窗口上选择值后,按钮确定,传递给父窗口上显示,但在子窗口上点确定时,发生了 火狐会直接提交表单的情况,所以在 form里 onSubmit="return false;" 然后
button 里 onclick="this.form.submit();"避免自动提交,现在需要判断提交时有没有在子窗口选择过
所以要加个判断
你写个方法 ,判断下你的条件 。
符合的再 document.getElementById("form1").submit();
function whatLength(x)
{
if (x>1)
submit();
else
return false;
}
onclick="if(document.getElementById('testTab11').value.length<=1){alert('请xxxxxxxxx');return false;}this.form.submit();"