|
|
|
ถามเรื่องการเพิ่มแถว ในการกรอกข้อมูลทีละหลาย ๆ reccord ครับ |
|
|
|
|
|
|
|
จากตัวอย่างคลิกแล้วมันนิ่ง เลยครับ :)
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<script language="javascript">
function fncCreateElement(){
var mySpan = document.getElementById('mySpan');
var myLine = document.getElementById('hdnLine');
myLine.value++;
// Create input text
var myElement1 = document.createElement('input');
myElement1.setAttribute('type',"text");
myElement1.setAttribute('name',"txtGalleryName"+myLine.value);
myElement1.setAttribute('id',"txt"+myLine.value);
mySpan.appendChild(myElement1);
// Create input file
var myElement2 = document.createElement('input');
myElement2.setAttribute('type',"file");
myElement2.setAttribute('name',"fileUpload"+myLine.value);
myElement2.setAttribute('id',"fil"+myLine.value);
mySpan.appendChild(myElement2);
// Create <br>
var myElement3 = document.createElement('<br>');
myElement3.setAttribute('id',"br"+myLine.value);
mySpan.appendChild(myElement3);
}
function fncDeleteElement(){
var mySpan = document.getElementById('mySpan');
var myLine = document.getElementById('hdnLine');
if(myLine.value > 1 )
{
// Remove input text
var deleteFile = document.getElementById("txt"+myLine.value);
mySpan.removeChild(deleteFile);
// Remove input file
var deleteFile = document.getElementById("fil"+myLine.value);
mySpan.removeChild(deleteFile);
// Remove <br>
var deleteBr = document.getElementById("br"+myLine.value);
mySpan.removeChild(deleteBr);
myLine.value--;
}
}
</script>
<body>
<form action="php_multiple_upload5.php" method="post" name="form1" enctype="multipart/form-data">
<input type="text" name="txtGalleryName1"><input type="file" name="fileUpload1">
<input name="btnCreate" type="button" value="+" onClick="JavaScript:fncCreateElement();">
<input name="btnDelete" type="button" value="-" onClick="JavaScript:fncDeleteElement();"><br>
<span id="mySpan"></span>
<input name="hdnLine" type="hidden" value="1">
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
|
|
|
|
|
Date :
2010-09-06 12:35:34 |
By :
dev_ngo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ของผมเป็นแบบนี้อ่ะครับ
Code (PHP)
<?
include_once '../includes/connect.php';
?>
<script src="../includes/js/jquery/jquery.form.js" type="text/javascript"></script>
<script type="text/javascript" src="../includes/js/jquery/jquery.datepick.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#myForm").submit(function () {
if($("#popupDatepicker").val() == ''){
alert("คุณไม่ได้กรอก วันที่");
return false;
}
else if($("#ph").val() == ''){
alert("คุณไม่ได้กรอกค่า ph");
return false;
}
else if($("#temp").val() == 'เช้า:'){
alert("คุณไม่ได้กรอกค่า อุณหภูมิ");
return false;
}
else if($("#lux").val() == 'เช้า:'){
alert("คุณไม่ได้กรอกค่า ความเข้มแสง");
return false;
}
else if($("#grow").val() == ''){
alert("คุณไม่ได้กรอกค่า ความเจริญเติบโต");
return false;
}
else if($("#product").val() == ''){
alert("คุณไม่ได้กรอกค่า ผลผลิต");
return false;
}
});
});
</script>
<script type="text/javascript">
$(function() {
$('#popupDatepicker').datepick({dateFormat: 'yyyy-mm-dd'});
$('#inlineDatepicker').datepick({onSelect: showDate});
});
function showDate(date) {
alert('The date chosen is ' + date);
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$('#myForm').ajaxForm({
dataType: 'json',
success: function processJson(resPonse) {
if(resPonse==1){
$('#Loading').hide();
$('#Loading1').show();
$('#Loading1').fadeOut(1500);
$('#myForm').reset();
} else {
$('#Loading1').hide();
$('#Loading').show();
$('#Loading1').show(1500);
}
}
});
});
function clearValue(obj,text) {
if ( obj.value == text ) obj.value = '';
}
function checkValue(obj,text) {
if ( obj.value == '' ) obj.value = text;
}
</script>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td style="border: 1px dashed #dedbd1; padding: 6px; margin: 1px; background-color: #ebe9e1; font-weight: bold; font-size: 15px;">เพิ่มข้อมูลการทดลอง</td></tr>
<tr>
<td align="left" style="padding-left:5px; height:29px; line-height:29px;"><a href="javascript:LoadContentDIV('dataAdd.php');">[+] เพิ่มข้อมูลรายบ่อ</a></td></tr>
</table>
<form name="myForm" id="myForm" action="dataAdd_script.php" method="post">
<table width="100%" cellpadding="9" cellspacing="0" border="0">
<tr>
<td width="5%" class="TD_title">วันที่: </td> <td align="left" width="95%"><input name="popupDatepicker" type="text" class="textbox" value="<? echo date('Y-m-d') ?>" id="popupDatepicker" > </td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#dedbd1">
<tr>
<td width="7%" height="25" rowspan="2" align="center" bgcolor="#ebe9e1"><strong>บ่อ</strong></td>
<td width="7%" height="25" rowspan="2" align="center" bgcolor="#ebe9e1"><strong>PH</strong></td>
<td height="20" colspan="2" align="center" bgcolor="#ebe9e1"><strong>อุณหภูมิ</strong></td>
<td height="20" colspan="2" align="center" bgcolor="#ebe9e1"><strong>ความเข้มแสง</strong></td>
<td width="11%" height="25" rowspan="2" align="center" bgcolor="#ebe9e1"><strong>การเจริญเติบโต</strong></td>
<td width="7%" height="25" rowspan="2" align="center" bgcolor="#ebe9e1"><strong>น้ำหนักเปียก</strong></td>
<td width="7%" height="25" rowspan="2" align="center" bgcolor="#ebe9e1"><strong>น้ำหนักแห้ง</strong></td>
</tr>
<tr>
<td width="10%" height="25" align="center" bgcolor="#EBE9E1">เช้า</td>
<td width="10%" height="25" align="center" bgcolor="#EBE9E1">บ่าย</td>
<td width="7%" height="25" align="center" bgcolor="#EBE9E1">เช้า</td>
<td width="7%" height="25" align="center" bgcolor="#EBE9E1">บ่าย</td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#FFFFFF"><select name="pool" id="pool">
<option>เลือกบ่อ..</option>
<?
$res1 = Query("select * from algaepool where status = 'y' ");
$pool_count = mysql_num_rows($res1);
if($pool_count > 0) {
while($poolArr=mysql_fetch_array($res1)){
?>
<option value="<?=$poolArr['id']?>"><?=$poolArr['name']?></option>
<?
}
}
?>
</select></td>
<td height="25" align="center" bgcolor="#FFFFFF"><label>
<input type="text" name="ph" id="ph" class="textboxshort" />
</label></td>
<td height="25" align="center" bgcolor="#FFFFFF"><label>
<input type="text" name="temp" id="temp" class="textboxshort" />
</label></td>
<td height="25" align="center" bgcolor="#FFFFFF"><label>
<input type="text" name="temp_after" id="temp_after" class="textboxshort" />
</label></td>
<td height="25" align="center" bgcolor="#FFFFFF"><label>
<input type="text" name="lux" id="lux" class="textboxshort" />
</label></td>
<td height="25" align="center" bgcolor="#FFFFFF"><label>
<input type="text" name="lux_after" id="lux_after" class="textboxshort" />
</label></td>
<td height="25" align="center" bgcolor="#FFFFFF"><label>
<input type="text" name="grow" id="grow" class="textboxshort" />
</label></td>
<td height="25" align="center" bgcolor="#FFFFFF"><label>
<input type="text" name="wet" id="wet" class="textboxshort" />
</label></td>
<td height="25" align="center" bgcolor="#FFFFFF"><label>
<input type="text" name="dry" id="dry" class="textboxshort" />
</label></td>
</tr>
</table>
<p>
<label>
<input type="button" name="multi" id="multi" value="+ เพิ่มแถว" class="buttonplus" align="right"/>
</label>
</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div id="buttonDiv"><input type="submit" name="button1" value="บันทึก" class="button" >
<input type="button" name="button2" value="ย้อนกลับ" onclick="javascript:LoadContentDIV('timeList.php');" class="button"></div>
<div id="Loading" style="padding: 10px; text-align: center; display:none; color: red;"><img src="../images/loader_twt.gif" /> กำลังบันทึกข้อมูล..</div></td>
</tr>
</table>
</form>
|
|
|
|
|
Date :
2010-09-06 12:41:34 |
By :
dev_ngo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|