|
 |
|
ขอโค๊โพ่มแบบไม่รู้จบคะ อยากได้แบบเป็นselect กดปุ่มเพิ่มแบบไปเรื่อยๆใส่ในฐานข้อมูลตารางเดียวกันคะ |
|
 |
|
|
 |
 |
|
อิๆๆๆ มีครับ พวก WBI ถนัด
|
 |
 |
 |
 |
Date :
2009-06-01 17:08:28 |
By :
nongjen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาแบบ นี้ไปแก้ไขเองละกันนะ เพราะตอนนี้มีแบบนี้ แบบที่นายต้องการเป๊ๆ ขี้เกียจเขียนให้แล้วอ่ะ ลบไปแล้ว
ตัวอย่างนะ ถ้าใช่ก็บอกจะได้ให้ Code ไป

|
 |
 |
 |
 |
Date :
2009-06-01 17:15:52 |
By :
nongjen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อธิบายนิดนึง เพิ่ม ลบ แก้ไขอยู่ในนี้หมดเลย
|
 |
 |
 |
 |
Date :
2009-06-01 17:16:34 |
By :
nongjen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือถ้ากดปุ่มเพิ่มจะเพิ่มแถวที่สี่ให้กรอกอีกอะคะ
|
 |
 |
 |
 |
Date :
2009-06-01 17:19:13 |
By :
vanda_buu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง javascript นี้ดูนะครับ
script type="text/javascript"><!--
var gFiles = 0;
function addFile() {
var li = document.createElement('li');
li.setAttribute('id', 'file-' + gFiles);
li.innerHTML = '<input type="text" name="name[]"><span onclick="removeFile(\'file-' + gFiles + '\')" style="cursor:pointer;">Remove</span>';
document.getElementById('files-root').appendChild(li);
gFiles++;
}
function removeFile(aId) {
var obj = document.getElementById(aId);
obj.parentNode.removeChild(obj);
}
--></script>
<span onclick="addFile()" style="cursor:pointer;">Add</span>
<ol id="files-root">
<li><input type="text" name="name[]">
</ol>
<?php
for($i=0;$i<count($_POST["name"]);$i++)
{
if($_POST["name"][$i] != "")
{
echo $_POST["name"][$i]."<br>";
}
}
?>
|
 |
 |
 |
 |
Date :
2009-06-01 17:36:40 |
By :
meepoohbugbear |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งั้นไปดู การเพิ่มข้อมูลแบบ array เลย
https://www.thaicreate.com/php/php-html-mutil-file-field-upload.html
|
 |
 |
 |
 |
Date :
2009-06-01 17:38:48 |
By :
nongjen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ที่ผมเขียนจะ คล้ายๆ กับของคุณ ME เป็น dynamic html ครับ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<title>unlimit add</title>
<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>
</head>
<body>
<?php
if (isset($_POST['add'])){
//mysql_connect('localhost','root','password');
if (empty($_POST['f1'])){
$_POST['f1']=array();
}
foreach($_POST['f1'] as $f1){
$query = "INSERT INTO tb1(f1) VALUES('$f1')";
echo "<br />$query";
//$res = mysql_query($query);
//if (!$res){
// echo "\n<br />".mysql_error();
//}
}
}else{
echo 'nodata';
}
?>
<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>
</body>
</html>
reference
http://cakephp.jitwitya.com/post/javascript-dynamic-add-textbox
|
 |
 |
 |
 |
Date :
2009-06-01 17:44:08 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณคะจะลองดูน้ะคะ
|
 |
 |
 |
 |
Date :
2009-06-01 18:16:05 |
By :
vanda_buu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อยากได้ Code ของ คุณ nongjenny ครับ
post มาให้ด้วย
|
 |
 |
 |
 |
Date :
2009-07-17 17:15:31 |
By :
Backer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เก็บๆ เทคนิค 
|
 |
 |
 |
 |
Date :
2009-07-17 19:01:40 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อยากได้ Code คุณ Nongjenny เหมือนกันคะ โพสให้หน่อยนะคะ ขอบคุณมากๆ
|
 |
 |
 |
 |
Date :
2009-07-18 09:32:09 |
By :
มือใหม่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|