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

    Post Is it possible to assign values to document.getElementsByName('field')

    I have to update the rowid(assigned to checkbox) whenever the textbox value is updated and this needs updating value of document.getElementsByName('rf_select[]') when checkbox value matches the textbox id. There can be mutliple number of rows each with a uniqueID (checkbox value) that matches with the textboxID onload.

    Code :-


    <td align="center"><input type='checkbox' name='rf_select[]' id='rf_select' value="rowId" CHECKED border="none"/>
    <td align="left"><input type='text' name='policy_no' id="rowId" size='25' value="test" onBlur=handleRowId('policy_no'); /></td>

    <script language="javascript">
    function handleRowId(){
    var arr = new Array();
    var rowarr = new Array();
    arr = document.getElementsByName('policy_no');
    rowarr = document.getElementsByName('rf_select[]');
    for(var i = 0; i < arr.length; i++)
    {
    var obj = arr.item(i); //alert(obj.id + " = " + obj.value);
    for(var j=0; j< rowarr.length; j++){
    if(rowarr[j].value == obj.id){
    document.getElementsByName('rf_select')[j].value = rowarr[j].value+"#@#"+obj.value;
    }
    }
    }
    }
    </script>

    I am having problem assigning values here - document.getElementsByName('rf_select')[j].value = rowarr[j].value+"#@#"+obj.value;


    Any help is appreciated.
    Last edited by chuck_17; 12-29-2010 at 05:14 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,620
    Thanks
    78
    Thanked 4,388 Times in 4,353 Posts
    You do NOT have any fields on that page named "rf_select".

    That may be the name in PHP, but in the browser their name really and truly *IS* "rf_select[]".

    The browser's DOM doesn't treat the "[]" in the name special the way PHP does.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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