 |
ขอรบกวนแก้ไขโค๊ด ในการเลือก Radio แล้วให้ซ่อน/แสดง textarea ครับ |
|
 |
|
|
 |
 |
|
Code (JavaScript)
$('input[name="showHideTextarea"]').click(function(){
let b=$(this).val()==='Approve';
$('textarea').css({ display: b ? 'none' : 'block'}).val('');
});
|
ประวัติการแก้ไข 2022-11-24 11:05:10
 |
 |
 |
 |
Date :
2022-11-24 11:04:45 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณพี่ ๆ ทุกท่านมาก ๆ ครับ
ผมนั่งแก้โค๊ดตั้งนานแสนนาน
|
 |
 |
 |
 |
Date :
2022-11-24 11:46:15 |
By :
pukmtec |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณพี่ mr.v มาก ๆ ครับ
ที่ให้คำแนะนำ บางทีผมก็สับสน ไปเจอโค๊ดมาก็เป็นแบบนี้ ผมก็เลยทำตามไปนั้นเลยครับ
|
 |
 |
 |
 |
Date :
2022-11-24 16:07:16 |
By :
pukmtec |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวอย่าง Code ที่ทำให้ เลือก Radio แล้วให้ซ่อน/แสดง textarea ครับ
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
<input type="radio" id="option1" name="option" value="1">
<label for="option1">อนุมัติ</label><br>
<input type="radio" id="option2" name="option" value="2">
<label for="option2">ไม่อนุมัติ</label><br>
<input type="submit" value="Submit"><br><br>
<textarea id="text" rows="4" cols="50" placeholder="* กรุณาให้เหตุผลของการ 'ไม่อนุมัติ' "></textarea>
</form>
<script>
// Get the elements by their id
var option1 = document.getElementById("option1");
var option2 = document.getElementById("option2");
var text = document.getElementById("text");
// Hide the textarea by default
text.style.display = "none";
// Define a function that will show or hide the textarea
function showHideText() {
// Check which radio button is selected
if (option1.checked) {
// If option 1 is selected, hide the textarea
text.style.display = "none";
} else if (option2.checked) {
// If option 2 is selected, show the textarea
text.style.display = "block";
}
}
// Add event listeners to the radio buttons
option1.addEventListener("click", showHideText);
option2.addEventListener("click", showHideText);
</script>
</body>
</html>
|
ประวัติการแก้ไข 2023-04-13 20:36:02
 |
 |
 |
 |
Date :
2023-04-13 20:35:13 |
By :
doanga2007 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<input type="radio" />
ุ้้ถ้าทันตอนที่เขียน xhtml จะ Get
สรุปได้ Mix ระหว่าง xhtml + html5
ได้ตัวแถมปิด tag->input ด้วย
้น่าจะต้องศึกษา html5 ก่อน
<input type="text" name="xxx">
เพราะการพัฒนา Dynamic Web ยังไงต้องอาศัยภาษา html ในการ Render
|
 |
 |
 |
 |
Date :
2023-04-20 08:07:37 |
By :
fossil31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|