how to make an array of button works

This is a discussion on "how to make an array of button works" within the JavaScript Forum section. This forum, and the thread "how to make an array of button works are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 24th, 2006, 13:15
New Member
Join Date: Dec 2006
Location: Kuala Lumpur
Age: 29
Posts: 1
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: Select all
<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>
Attached Images
File Type: jpg help.jpg (59.5 KB, 27 views)
Reply With Quote

  #2 (permalink)  
Old Dec 27th, 2006, 12:35
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: how to make an array of button works

Pass the button id into your functions like shown below.
Code: Select all
onclick="clickyes('b1');"
You could make this even more general by using this syntax:
Code: Select all
onclick="clickyes(this);"
'this' is the object calling the function.
Reply With Quote
Reply

Tags
array, array of button

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make Button Open new window in flash? bunnyface Flash & Multimedia Forum 4 Feb 27th, 2008 21:41
How do I make a YouTube style on-screen play button. Zonglars Flash & Multimedia Forum 3 Dec 29th, 2007 08:12
how to make an image button.. s_mazhar Graphics and 3D 6 Dec 27th, 2005 18:24
Sorting a new array from an existing array Ozeona Flash & Multimedia Forum 2 Sep 20th, 2005 08:43
array unable to check another array so as to be displayed Ozeona Flash & Multimedia Forum 1 Aug 5th, 2005 10:26


All times are GMT. The time now is 19:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43