|
 |
|
ต้องการนำข้อความ(value)ใน checkbook มาต่อกันโดยมีเครื่องหมาย , ครั้นครับ ไม่รู้ว่าต้องทำอย่างไร |
|
 |
|
|
 |
 |
|
Code (PHP)
<fieldset style="width:400px;"><legend><strong>เลือกข้อมูลแสดง</strong></legend>
<form method="post" action="admin_index.php">
<input type="checkbox" name="chk[]" value="UserID"/>UserID
<input type="checkbox" name="chk[]" value="Password"/>Pasword
<input type="checkbox" name="chk[]" value="Name"/>Name
<input type="checkbox" name="chk[]" value="Type"/>Type
<input type="checkbox" name="chk[]" value="Status"/>Status
<input type="submit" name="chkSubmit" value="ตกลง" />
</form>
</fieldset>
<?php
if(isset($_POST['chkSubmit'])) {
$chk = "";
for($i=0;$i<count($_POST['chk']);$i++){
$chk .= $_POST['chk'][$i].", ";
}
$SumChk = substr($chk, 0, -2); // ลบ , หลังสุด
echo $SumChk;
}
?>
|
 |
 |
 |
 |
Date :
2014-12-02 01:33:32 |
By :
sabaitip |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ คุณCop และคุณChaidhanan มากๆเลยครับ ท่านทั้ง2 ช่วยผมได้เยอะเลยครับ เทคนิคขั้นเทพทั้งนั้น ขอบคุณครับ ^___^
|
 |
 |
 |
 |
Date :
2014-12-02 08:06:21 |
By :
udorn555 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เพิ่มเติมอีกนิดครับ
ถ้าต้องการให้คลิกข้อมูลใน checkbok แล้วไปแสดงใน combobox ด้วยครับ จาก code ที่ผมทำ
Code (PHP)
<form method="post" action="test2.php">
<input type="checkbox" name="chk[]" value="UserID"/>UserID
<input type="checkbox" name="chk[]" value="Password"/>Password
<input type="checkbox" name="chk[]" value="Name"/>Name
<input type="checkbox" name="chk[]" value="Type"/>Type
<input type="checkbox" name="chk[]" value="Status"/>Status
<input type="submit" name="chkSubmit" value="ตกลง" />
</form>
<form>
<select>
<? if(isset($_POST['chkSubmit'])) {
for($i=0;$i<count($_POST['chk']);$i++){ ?>
<option><? echo $_POST['chk'][$i];?></option><?
}
}?>
</select>
</form>
ผลที่ได้คือ มันแสดงค่าออกมา คือเมื่อเลือก UserID กับ Password มันจะแสดงเพียง UserID ค่าเดียวครับ แก้ไขยังไงครับ ^___^
|
 |
 |
 |
 |
Date :
2014-12-02 08:57:25 |
By :
udorn555 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ้อได้ละครับ ผมปรับเป็น
Code (PHP)
<form method="post" action="test555.php">
<input type="checkbox" name="chk[0]" value="UserID"/>UserID
<input type="checkbox" name="chk[1]" value="Password"/>Password
<input type="checkbox" name="chk[2]" value="Name"/>Name
<input type="checkbox" name="chk[3]" value="Type"/>Type
<input type="checkbox" name="chk[4]" value="Status"/>Status
<input type="submit" name="chkSubmit" value="ตกลง" />
</form>
<form>
<select>
<? if(isset($_POST['chkSubmit'])) {
for($i=0;$i<count($_POST['chk']);$i++){ ?>
<option><? echo $_POST['chk'][$i];?></option><?
}
}?>
</select>
</form>
|
 |
 |
 |
 |
Date :
2014-12-02 09:05:21 |
By :
udorn555 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมไม่เห็นว่า code 2 อันนี้มันจะต่างกันตรงไหน เลยCode (PHP)
<form method="post" action="test2.php">
<input type="checkbox" name="chk[]" value="UserID"/>UserID
<input type="checkbox" name="chk[]" value="Password"/>Password
<input type="checkbox" name="chk[]" value="Name"/>Name
<input type="checkbox" name="chk[]" value="Type"/>Type
<input type="checkbox" name="chk[]" value="Status"/>Status
<input type="submit" name="chkSubmit" value="ตกลง" />
</form>
<form>
<select>
<? if(isset($_POST['chkSubmit'])) {
for($i=0;$i<count($_POST['chk']);$i++){ ?>
<option><? echo $_POST['chk'][$i];?></option><?
}
}?>
</select>
</form>
Code (PHP)
<form method="post" action="test555.php">
<input type="checkbox" name="chk[0]" value="UserID"/>UserID
<input type="checkbox" name="chk[1]" value="Password"/>Password
<input type="checkbox" name="chk[2]" value="Name"/>Name
<input type="checkbox" name="chk[3]" value="Type"/>Type
<input type="checkbox" name="chk[4]" value="Status"/>Status
<input type="submit" name="chkSubmit" value="ตกลง" />
</form>
<form>
<select>
<? if(isset($_POST['chkSubmit'])) {
for($i=0;$i<count($_POST['chk']);$i++){ ?>
<option><? echo $_POST['chk'][$i];?></option><?
}
}?>
</select>
</form>
|
 |
 |
 |
 |
Date :
2014-12-02 09:16:36 |
By :
gaowteen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทุกความคิดเห็นครับ ผมจะปรับตามคำแนะนำครับ ^^
|
 |
 |
 |
 |
Date :
2014-12-02 13:50:24 |
By :
udorn555 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|