View: 3136|Reply: 8
|
TOLONG LAGI : Nak disable kan field in pHP
[Copy link]
|
|
salam uols,
Nak mintak tolong lagi.
Macam mana nak wat kalau ali ada radio button YES and NO followed by 2 field free text. Sekiranya ali pilih YES maka, dua filed tersebut akan jadi editable, tetapi sekiranya ali pilih NO, maka kedua2 field tersebut akan jadi disable(tidak boleh key in data)
Terima kasih |
|
|
|
|
|
|
|
kalau nak buat jadi terus rasanya macam kene guna js je |
|
|
|
|
|
|
|
1# alisetan
try ni..
- <script>
- function decide(yesorno)
- {
- var num = document.namaform.elements.length
- var current = 0
- if(yesorno == 'disable')
- {
- while(current<num)
- {
- document.namaform.elements[current].disabled = true
- current++
- }
- }
- else
- {
- while(current<num)
- {
- document.namaform.elements[current].disabled = false
- current++
- }
- }
- }
- </script>
- Yes: <input type="radio" name="pilihan" value="Yes" onClick="decide('enable')">
- No: <input type="radio" name="pilihan" value="No" onClick="decide('disable')">
- <?php
- echo "<form name='namaform'>";
- echo "text1 <input type='text' name='text1' value='textvalue1'><br>";
- echo "text2 <input type='text' name='text2' value='textvalue2'><br>";
- echo "</form>";
- ?>
Copy the Code |
|
|
|
|
|
|
|
3# ana_una
dahsyat la akak nih |
|
|
|
|
|
|
|
4# dune1989
ngade.... |
|
|
|
|
|
|
|
terer la akak n... bila nak start kelas... tak sabar nak belajar n |
|
|
|
|
|
|
|
3# ana_una
tengkui byk2 akak |
|
|
|
|
|
|
| |
|