我想在输入表单中使用datepicker保留前缀 并且我的前缀来自我的SQL数据库,我首先尝试使用SQL数据中的echo来使用初始值,但是每次我从datepicker中选择一个日期时,它总是替换所有值。
这是我的日期选择器脚本
<script>
$(function() {
$( ".datepicker" ).datepicker({ });
$( ".datepicker2" ).datepicker({ });
});
</script>
这是为了让脚本保留前缀
<script>
$('input.datepicker').keyup(function(){
var prefix = 'prefix_';
if(!(this.value.match('^prefix_'))){
this.value = prefix;
}
});
$('input.datepicker').blur(function(){
var prefix = 'prefix_';
if(!(this.value.match('^prefix_'))){
this.value = prefix;
}
});
</script>
我想要的结果是这样的:
前缀_2018-10-17
我想要的前缀来自mySQL数据库
这是我重复表的php脚本
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['nopek']; ?></td>
<td><?php echo $row_Recordset1['pengguna']; ?></td>
<td><?php echo $row_Recordset1['kbo']; ?></td>
<td><?php echo $row_Recordset1['idposition']; ?></td>
<td><?php echo $row_Recordset1['jabatan']; ?></td>
<td><?php echo $row_Recordset1['fungsi']; ?></td>
<td><?php echo $row_Recordset1['direktorat']; ?></td>
<td><?php echo $row_Recordset1['psn']; ?></td>
<td><?php echo $row_Recordset1['costcenter']; ?></td>
<td><?php echo $row_Recordset1['unit']; ?></td>
<td><?php echo $row_Recordset1['wsrule']; ?></td>
<td>
<?php if (!empty ($row_Recordset1['nopek']) ) { // Show if recordset not empty ?>
<input name="id_check[]" type="checkbox" id="id" value="<?php echo $row_Recordset1['id']; ?>" />
<?php } // Show if recordset not empty ?><label for="id"></label></td>
<td><?php if (!empty ($row_Recordset1['nopek']) ) { // Show if recordset not empty ?>
<select name="wsrule[]" id="wsrule">
<option value="0"></option>
<?php
do {
?>
<option value="<?php echo $row_Recordset2['wsrule']?>.<?php echo $row_Recordset1['nopek'];?>"><?php echo $row_Recordset2['wsrule']."| ".$row_Recordset2['keterangan']?></option>
<?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
$rows = mysql_num_rows($Recordset2);
if($rows > 0) {
mysql_data_seek($Recordset2, 0);
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
}
?>
</select>
<?php } // Show if recordset not empty ?></td>
<td>
<input name="tgl[]" type="text" class="datepicker" readonly="readonly" value="prefix_" /></td>
<td><input name="tgl2[]" type="text" class="datepicker2" readonly="readonly" /></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
任何人都可以帮助我。