我的代码中添加了点击添加的行。添加行效果很好但是在保存按钮不起作用之后。我使用JavaScript为此但没有控件转移到该代码点击保存按钮。
<?php
include_once("noaccess.php");
include_once(CLASS_PATH."fetch_service.php");
$objfetch = new fetchService();
include_once(CLASS_PATH."update_service.php");
$objupdate = new updateService();
?>
<!-- -->
<div class="dashboard">
<h2>Update Extension</h2>
<?php
$result = $objfetch->fetch_ext("decode(password, '\$VarahaMVC\$') as password,id,firstname,","where `account_id`='".$_SESSION['account_id']."' ORDER BY `id`");
$i = "1";
echo $cnt = sizeof($result);
if ($cnt == $row3['num_of_lines']){
echo '<span style="color:#df0909;text-align:center;"><h3>Maximum Extension Limit Reached.</span></h3>';
}
?>
<!--**
** EDIT EXTENSION
*-->
<?php if(isset($_COOKIE['msg'])){?>
<div class="msg">
<span><?php echo $_COOKIE['msg'];setcookie("msg","",time()-5,"/");?></span>
<div class="clear"></div>
</div>
<?php }?>
<?php if(isset($_COOKIE['err'])){?>
<div class="err">
<span><?php echo $_COOKIE['err'];setcookie("err","",time()-5,"/");?></span>
<div class="clear"></div>
</div>
<?php }?>
<div id="umcloader" style="float:left;"></div>
<form name="frmextension" id="frmextension" action="" method="post">
<input type="hidden" id="hid_mode" value="<?php echo $mode;?>" />
<table id="tblext" class="tbl_altcolor shadow" style="width:98%;margin-left:20px" align="left">
<thead>
<tr align="center" bgcolor="#999999" height="25">
<th width="8%">Name</th>
<th width="6%">Extension</th>
<th width="8%">Password</th>
<th width="8%">Confirm Password</th>
<th width="8%">number</th>
</tr>
</thead>
<tbody style=" border-collapse:collapse">
<input type="hidden" name="case" id="case" value="update_ext" />
<?php
foreach($result as $row)
{
?>
<tr align="center">
<td width="8.5%">
<input type="hidden" name="hid_extid[<?php echo $i;?>]" id="hid_extid<?php echo $i;?>" value="<?php echo $row['id'];?>"/>
<input type="text" name="fname[<?php echo $i;?>]" id="fname<?php echo $i;?>" class="input required" placeholder="Enter First Name" value="<?php echo $row['firstname'];?>" style="width:80% !important" />
</td>
<td width="85px">
<?php echo $row['ext_number'];?>
<input type="hidden" name="ext[<?php echo $i;?>]" id="ext<?php echo $i;?>" class="input required digits extvalue" placeholder="Enter Extension" value="<?php echo $row['ext_number'];?>" style="width:80% !important" />
</td>
<td width="113px">
<input type="password" name="password[<?php echo $i;?>]" id="password<?php echo $i;?>" class="input required" placeholder="Enter Password" value="<?php echo $row['password'];?>" style="width:70% !important" />
</td>
<td width="113px">
<input type="password" name="cpass[<?php echo $i;?>]" id="cpass<?php echo $i;?>" equalto="#password<?php echo $i;?>" class="input required" placeholder="Enter Confirm Password" value="<?php echo $row['password'];?>" style="width:70% !important" />
</td>
<td width="129px">
<select name="did[<?php echo $i;?>]" id="did<?php echo $i;?>" class="input validdid chkdid" style="width:90% !important">
<option value="">Select</option>
<?php
global $mysqli;
$did_array = array();
$query = "select `id`, `DID` from `did` where account_id='".$_SESSION['account_id']."' and `DID_type` in ('E','X')";
$result = $mysqli->query($query);
while($row2 = $result->fetch_array(MYSQLI_ASSOC)){
$did_array[$row['id']] = $row['DID'];
?>
<option value="<?php echo $row2['id'];?>" <?php echo $row['did_id']==$row2['id'] ? "selected":"";?>><?php echo $row2['DID'];?></option>
<?php }?>
</select>
<input type="hidden" name="old_didid[<?php echo $i;?>]" value="<?php echo $row['did_id'];?>">
</td>
</tr>
<?php $i++;} ?>
</tbody>
<tfoot>
<tr>
<td colspan="13">
<?php if($cnt<$row3['num_of_lines']){ ?>
<span style="float:left; margin:5px"><input type="button" name="add" id="add" class="btn" value="Add" /></span>
<span style="float:left; margin:5px"><a href="<?php echo SITE_URL;?>index.php?view=upload_csv" id="upload_csv" name="upload_csv" class="btn">Upload CSV</a>
<?php }if($cnt>1){ ?>
<span style="margin-left:5px; float:left; margin:5px"><input type="button" name="remove" id="remove" class="btnremove" value="Remove" style="display:none" /></span>
<?php } ?>
<span style="float:left; margin:5px"><input type="button" name="add" id="add" class="btn" value="Add" style="display:none" /></span>
<span style="margin-left:5px; float:left; margin:5px"><input type="button" name="remove" id="remove" class="btnremove" value="Remove" style="display:none"/></span>
</td>
</tr>
</tfoot>
</table>
<div class="clear"> </div>
<div style="float:left; margin:00px 10px 10px 30px;"><input type="button" name="save_ext" id="save_ext" class="btn" value="Save" /></div>
</form>
</div>
<script>
$(document).on("click", "#save_ext", function () {
var chk = "0";
$("#frmextension").validate({
errorPlacement: function(error, element) { }
});
$(".validdid").removeClass("error");
$(".extvalue").removeClass("error");
for(j=0;j<=$(".validdid").length;j++)
{
for(i=j+1;i<=$(".validdid").length;i++)
{
/* ---- for DID ---- */
if(($("#did"+i).val() == $("#did"+j).val()) && (i>1))
{
if($("#did"+i).val()!="")
{
$("#did"+i).removeClass("valid");
$("#did"+i).addClass("error");
chk = "1";
}
}
/* ---- for EXTENSION ---- */
if(($("#ext"+i).val() == $("#ext"+j).val()) && (i>1))
{
if($("#ext"+i).val()!="")
{
$("#ext"+i).removeClass("valid");
$("#ext"+i).addClass("error");
chk = "1";
}
}
}
}
if(chk=="1"){return false;}
else{
$("#frmextension").submit();
}
});
</script>