|
|
|
ปุ่มเพิ่ม textfield อยากได้codeปุ่มที่ กดปุ่มแล้วจะเพิ่ม textfield ให้เรื่อยๆนะค่ะ พอจะมีมั้ยค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<script type="text/javascript">
//<![CDATA[
function addbox(){
var b=document.getElementById('inputboxes');
var el1=document.createElement("br");
var el2=document.createElement("input");
el2.name='f1[]';
el2.type='text';
el2.value='';
b.appendChild(el1);
b.appendChild(el2);
}
//]]>
</script>
//**********************
<form method="post" action="?" id="box">
<div id="inputboxes">
<?php foreach(array(1,2,3) as $n): ?>
<br /><input type="text" name="f1[]" value="" />
<?php endforeach; ?>
</div>
<input type="submit" name="$addbox" value="เพิ่ม>>" onclick="addbox();return false;" />
<input type="submit" name="add" value="บันทึก" />
</form>
|
|
|
|
|
Date :
2009-10-07 16:56:08 |
By :
somparn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Ajax Tutorial</title>
</head>
<script language="javascript">
function fncCreateElement(){
var mySpan = document.getElementById('mySpan');
var myElement1 = document.createElement('<input type="text" name="txt[]">');
myElement1.setAttribute('id',"txt1");
mySpan.appendChild(myElement1);
//*** Remove Element ***//
/*
var deleteEle = document.getElementById('txt1');
mySpan.removeChild(deleteEle);
*/
var myElement2 = document.createElement('<br>');
mySpan.appendChild(myElement2);
}
</script>
<body>
<span id="mySpan"></span>
<input name="btnButton" id="btnButton" type="button" value="Create" onClick="JavaScript:fncCreateElement();">
</body>
</html>
Thank & Ref : https://www.thaicreate.com/php/forum/002630.html
|
|
|
|
|
Date :
2009-10-07 16:59:09 |
By :
panyapol |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ส่วนนี่เป็นตัวอย่างการอ่านแบบ Multiple Input ครับ
Code (PageMultiInputTextField1.html)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<form action="PageMultiInputTextField2.php" method="post" name="form1">
<input type="text" name="txtSiteName[]"><br>
<input type="text" name="txtSiteName[]"><br>
<input type="text" name="txtSiteName[]"><br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
Code (PageMultiInputTextField2.php)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
for($i=0;$i<count($_POST["txtSiteName"]);$i++)
{
echo "txtSiteName $i = ".$_POST["txtSiteName"][$i]."<br>";
}
?>
</body>
</html>
Ref : Get Value from multiple text fields
|
|
|
|
|
Date :
2009-10-07 18:22:17 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เยี่ยมเลยคับทำอย่างนี้ได้ด้วย
|
|
|
|
|
Date :
2009-10-09 09:10:42 |
By :
apicha31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|