Results 1 to 2 of 2

Thread: javascript: getting html label values

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Location
    South Africa
    Posts
    105

    javascript: getting html label values

    Hi there

    I am using a checkbox and a corresponding label. When the user checks the checkbox I want to be able to retrieve the corresponding label value. How do I do this.

    Here is the relevant portion of my code

    <td>
    <input type = "checkbox" name = "checkuser" id= "checkuser" value = "userid" onClick = "getname()">
    </td>

    <td>
    <label for = "checkuser">usersurname, usersurname <label>
    </td>

    thanks

    langals

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    Here is an example:

    Code:
    <script language="JavaScript">
    
    function getname(chk){
    	alert(chk.value);
    }
    
    </script>
    <form name="LabelClicker">
    <input type = "checkbox" name = "checkuser" id= "checkuser" value = "userid" onClick = "getname(this)">
    </form>
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

Posting Permissions

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



Click Here to Expand Forum to Full Width