Reseller Domain Murah dan termurah di Indonesia? ya di ResellerCamp.
         
 

Forum PHP Indonesia

 
Advanced Search
   
 
Home Register FAQ Memberlist Usergroups  
 
 

Forum PHP Indonesia Forum Index HTML + Javascript untuk meng-enable/disable textbox sesuai pilihan selectbox
Display posts from previous:   
      All times are GMT + 7 Hours  

untuk meng-enable/disable textbox sesuai pilihan selectbox

Post new topic  Reply to topic

Tue Jul 21, 2009 11:15
Author Message
fed289
PHPnewbie
PHPnewbie


Joined: 08 Jul 2009
Posts: 14

Post subject: untuk meng-enable/disable textbox sesuai pilihan selectbox Reply with quote

sori, gan, klo pertanyaannya cupu, masih kurang familiar dengan JS nih..

saya punya selectbox yang valuenya YA dan TIDAK, saya pengen buat agar pas user seleksi TIDAK, maka textboxnya di-disable, klo tekan YA lagi, textbox-nya enabled lagi...
caranya gmana ya?

mohon pencerahannya Salute!
 
View user's profile Send private message
      Back To Top  

Tue Jul 21, 2009 13:01
Author Message
mul14
PHP Programmer
PHP Programmer


Joined: 01 Jun 2009
Posts: 133
Location: Yogyakarta

Post subject: Reply with quote

Pake jquery aja..

<script>
$().ready(function(){
if ($('select').val() == 'YA') {
$('input[type=text]').attr('disabled', 'disabled');
} else {
$('input[type=text]').removeAttr('disabled');
}
});
</script>

<form>
<select>
<option value="YA">YA</option>
<option value="TIDAK">TIDAK</option>
</select>
<input type="text" />
</form>
_________________
Join - http://framework.web.id
 
View user's profile Send private message Visit poster's website Yahoo Messenger
      Back To Top  

Thu Jul 23, 2009 04:05
Author Message
fed289
PHPnewbie
PHPnewbie


Joined: 08 Jul 2009
Posts: 14

Post subject: Reply with quote

wah, ok, thank you, gan~
 
View user's profile Send private message
      Back To Top  

Sun Nov 15, 2009 21:54
Author Message
esraldi
PHP Programmer
PHP Programmer


Joined: 15 Jun 2008
Posts: 168
Location: yogyakarta

Post subject: Reply with quote

wah kq g berhasil, misalkan yg ingin di disable bukan hanya text gmana? misalkan ada beberapa inputan yg akan qt disable ktka plhan 1, maka ada 3 inputan akan mati dan plhan 2, mka 2 yg mati n pil 3 mka 1 inputan yg mati. :-( help
_________________
esraldi
 
View user's profile Send private message Send e-mail
      Back To Top  

Mon Nov 16, 2009 11:08
Author Message
mochin
PHP Master
PHP Master


Joined: 17 Jun 2008
Posts: 348

Post subject: Reply with quote

ini aku coba sedikit. mudah2an bermanfaat :

Code:
<?php .

<!-- =============
file HTML==============  -->
<
script language=javascript>
function 
cekpilih(status)
{
    
a=status.value;
    if(
a==1)
    {
        
document.getElementById('satu').disabled false;
        
document.getElementById('dua').disabled false;
    }
    else if(
a==2)
    {
        
awal();
    }
}

function 
awal()
{
    
document.getElementById('satu').disabled true;
    
document.getElementById('satu').value='';
    
document.getElementById('dua').disabled true;
    
document.getElementById('dua').value='';
}
</script>
<BODY onload="awal();">
<table width='100%'>
    <tr>
        <td align='left' width='10%' >Jenis Pilihan</td>
        <td align='center' width='5%'>:</td>
        <td align='left'>
            <input type='radio' name='pilih' id='pilih' value='1' style="margin:1;" onclick="cekpilih(this);"  class='input'>Ya     
            <input type='radio' name='pilih' id='pilih' value='2' style="margin:1;" onclick="cekpilih(this);"  class='input'>Tidak
        </td>
    </tr>
    <tr>
        <td align='left'>Inputan</td>
        <td align='center'>:</td>
        <td align='left'>
            <input type='text' name='satu' id='satu'><br>
            <input type='text' name='dua' id='dua'>
        </td>
    </tr>
</table>
</body>
<!-- =============file HTML==============  --> ?>

_________________
Long Life Education
Berbagilah Dalam Pengetahuan "Copy Paste Generation"
 
View user's profile Send private message Yahoo Messenger
      Back To Top  

Wed May 26, 2010 18:26
Author Message
nakata
PHPnewbie
PHPnewbie


Joined: 06 Dec 2009
Posts: 10
Location: Surabaya

Post subject: Reply with quote

untuk master2, ak mau tanya klo dikembangin pake multiple checkbox yang d tampilin dari database... spt ini.... gimana ya caranya untuk enable disable data, ketika salah satu makanan di centang otomatis enable textbox jumlahnya. Confuse

Code:
<?php <table border="0" cellpadding="2" cellspacing="1" width="100%" style="border-collapse:collapse" bordercolor="#165455">
 <
tr>
    <
td width="50%" height="49" align="center">Pilih makanan</td>
    <
td width="50%" height="49" align="center">Jumlah Pesan</td>
</
tr>
<?
php
$result
=@mysql_query("SELECT * FROM makanan",$dbh) or die ("terjadi Kesalahan!");
 while(
$r=mysql_fetch_array($result))
 {
$ID=$r["ID"]; 
$NM=$r["NAMA"]; 

echo 
'
<tr>
    <td width="50%" height="22"><input type=checkbox name=\"'
.$ID.'\" value ='.$ID.'> '.$NM.'</td>
    <td width="50%" height="22" align="center"><input type="text" name=\"jml'
.$ID.'\" size="2" maxlength="1"></td>
</tr>'
;
 }

?>
</table> ?>
quit
 
View user's profile Send private message Visit poster's website
      Back To Top  
Post new topic  Reply to topic

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


      Back To Top  

Page 1 of 1
Jump to:  
Powered by phpBB © 2001, 2002 phpBB Group
Avalanche style by What Is Real © 2004