Click to See Complete Forum and Search --> : Dynamically change button's initial


rag84dec
02-05-2008, 01:06 AM
Hi,
I have an asp code which creates a grid or matrics (5 x 5 matrics).Each cell contains a button which will have an initial
.The initial will be read from a database.

say the database has these entries...table name is "TestSuite"
---------- ------- --------
| Initial | Name |
---------- ------- --------
| S | TestSuite1 |
-------------------------------
| R | Suite2
-------------------------------
|G | Suite3
-------------------------------
| T | Suite4
-------------------------------


Initially the button should contain "S" or the first entry of the database and on clicking the button it should change to the next initial say "R".

On clicking the button it should keep changing to the next entry till the last and again from first.


How can i do??...With javascript function??....Earlier i had a combo box which had all the initial in it.User had an option to select a particular "Initial'....Can any one please help me in having a dynamic button??....

Navcon
02-11-2008, 10:05 AM
You might want to first brush up on your DHTML and JavaScript skills (http://www.w3schools.com/). There's a number of ways to do what you're doing and it largely depends on your circumstances. You could for instance have your ASP write some JS for you that builds a global array like ['S', 'R', 'T']. When the user clicks the button it fires a JS function that changes the button.value to the next value in the array (so you may need to keep track of your array position globally as well). That would probably be the simplest way, you could get even more complex depending on what all it is you are trying to accomplish.