Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to make an array of button works

    Hello everybody....i really a need some help with this js here...well my page is like the code and pic below,as you all can see, its contain name,department and active column.The active column contain 2 button which is yes and no.What i want to do is....let say for example if the yes button on first row is click its become disabled and no button become active.The action of these 2 button will generate a value for HiddenField(activeval).I will like to apply the same action to the other rows as well respectively.I'm going to used this js with php generated page...thanking u all in advance for your time in reviewing my msg...may god bless u all.

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script language="javascript">
    function clickyes(){
    document.getElementById('b1').disabled=true;
    document.getElementById('b2').disabled=false;
    document.getElementById('activeval').value="yes";
    }
    function clickno(){
    document.getElementById('b1').disabled=false;
    document.getElementById('b2').disabled=true;
    document.getElementById('activeval').value="no";
    }
    </script>
    </head>
    
    <body>
    <table width="368">
    	<tr>
    		<td width="115" bgcolor="#999999">Name</td>
    		<td width="149" bgcolor="#ADADAD">Department</td>
    		<td width="88" bgcolor="#D2D2D2">Active</td>
    	</tr>
    	<tr>
    		<td bgcolor="#999999">Jamie</td>
    		<td bgcolor="#ADADAD">Coperate</td>
    		<td bgcolor="#D2D2D2"><input type="button" name="set1" id="b1" onclick="clickyes()" value="yes"/>
              <input type="button" name="set12" id="b2" onclick="clickno()" value="no"/>
          <input name="activeval" type="hidden" id="activeval" /></td>
    	</tr>
    		<tr>
    		<td bgcolor="#999999">Emily</td>
    		<td bgcolor="#ADADAD">Finance</td>
    		<td bgcolor="#D2D2D2"><input type="button" name="set1" id="b1" onclick="clickyes()" value="yes"/>
              <input type="button" name="set12" id="b2" onclick="clickno()" value="no"/>
              <input name="activeval" type="hidden" id="activeval" /></td>
    	</tr>
    		<tr>
    		<td bgcolor="#999999">Jamie</td>
    		<td bgcolor="#ADADAD">Human Resource </td>
    		<td bgcolor="#D2D2D2"><input type="button" name="set1" id="b1" onclick="clickyes()" value="yes"/>
              <input type="button" name="set12" id="b2" onclick="clickno()" value="no"/>
              <input name="activeval" type="hidden" id="activeval" /></td>
    	</tr>
    		<tr>
    		<td bgcolor="#999999">Oliver</td>
    		<td bgcolor="#ADADAD">It</td>
    		<td bgcolor="#D2D2D2"><input type="button" name="set1" id="b1" onclick="clickyes()" value="yes"/>
              <input type="button" name="set12" id="b2" onclick="clickno()" value="no"/>
              <input name="activeval" type="hidden" id="activeval" /></td>
    	</tr>	
    </table>
    </body>
    </html>

  • #2
    New Coder
    Join Date
    Nov 2006
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script language="javascript">
    function changeAttributes(a,b,c){
    	a.setAttribute('disabled','true');
    	document.getElementById(b).removeAttribute('disabled');
    	document.getElementById('activeval'+c).value=a.value;
    }
    </script>
    </head>
    
    <body>
    <table width="368">
    	<tr>
    		<td width="115" bgcolor="#999999">Name</td>
    		<td width="149" bgcolor="#ADADAD">Department</td>
    		<td width="88" bgcolor="#D2D2D2">Active</td>
    	</tr>
    	<tr>
    		<td bgcolor="#999999">Jamie</td>
    		<td bgcolor="#ADADAD">Coperate</td>
    		<td bgcolor="#D2D2D2"><input type="button" name="set1y" id="b1y" onclick="changeAttributes(this,'b1n',1)" value="yes"/>
              <input type="button" name="set1n" id="b1n" onclick="changeAttributes(this,'b1y',1)" value="no"/>
          <input name="activeval1" type="hidden" id="activeval1" /></td>
    	</tr>
    		<tr>
    		<td bgcolor="#999999">Emily</td>
    		<td bgcolor="#ADADAD">Finance</td>
    		<td bgcolor="#D2D2D2"><input type="button" name="set2y" id="b2y" onclick="changeAttributes(this,'b2n',2)" value="yes"/>
              <input type="button" name="set2n" id="b2n" onclick="changeAttributes(this,'b2y',2)" value="no"/>
              <input name="activeval2" type="hidden" id="activeval2" /></td>
    	</tr>
    		<tr>
    		<td bgcolor="#999999">Jamie</td>
    		<td bgcolor="#ADADAD">Human Resource </td>
    		<td bgcolor="#D2D2D2"><input type="button" name="set3y" id="b3y" onclick="changeAttributes(this,'b3n',3)" value="yes"/>
              <input type="button" name="set3n" id="b3n" onclick="changeAttributes(this,'b3y',3)" value="no"/>
              <input name="activeval3" type="hidden" id="activeval3" /></td>
    	</tr>
    		<tr>
    		<td bgcolor="#999999">Oliver</td>
    		<td bgcolor="#ADADAD">It</td>
    		<td bgcolor="#D2D2D2"><input type="button" name="set4y" id="b4y" onclick="changeAttributes(this,'b4n',4)" value="yes"/>
              <input type="button" name="set4n" id="b4n" onclick="changeAttributes(this,'b4y',4)" value="no"/>
              <input name="activeval4" type="hidden" id="activeval4" /></td>
    	</tr>	
    </table>
    </body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •