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
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Java Script runtime

    Hi,
    i have multiple check box and text box for each check box.
    the check box value is given as text box name
    ex
    Checkbox
    <input type="checkbox" name="cBx" value="txtname1"/>

    Textbox
    <input type="text" name="txtname1" />

    how to get the text box value (txtname1) on calling the below function

    function get_textBox_value()
    {
    var c_chkBoxName = "";
    var c_txtBoxValue = "";
    for (var i=0; i < document.Formname.cBx.length; i++)
    {
    if (document.Formname.cBx[i].checked)
    {
    c_chkBoxName= document.Formname.cBx[i].value; //working fine...
    c_txtBoxValue = document.Formname.c_chkBoxName.value; // not working... how to pass the chkbox value for c_txtBoxName
    }
    }
    }

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Try

    c_txtBoxValue = document.Formname[c_chkBoxName].value;
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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