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

    Referring Javascript variable in input text value

    Hello

    I've been facing a problem assigning a javascript variable to an input text's value attribute.

    My code is as follows:
    var moduleCd = document.getElementById('client.moduleCd').value;
    var productSelectLen = productSelect.options.length;
    for(var i=0; i<productSelectLen; i++)
    {
    if(productSelect.options[i].selected)
    {
    var text = productSelect.options[i].text;
    var value = productSelect.options[i].value + ','+ moduleCd;

    }
    }

    //getting the table element
    var selectedPrtoductTable = document.getElementById('selectedPackagesTab');
    if(moduleCd == '<%= ProductConstant.MODULE_CODE_CRM %>' )
    {
    crmRow = selectedPrtoductTable.insertRow(selectedPrtoductTable.rows.length);
    crmRow.id = '<%= ProductConstant.MODULE_CODE_CRM %>';

    moduleCell = crmRow.insertCell(0);
    //alert("cell added" + moduleCell);
    // give this cell its own id
    moduleCell.id = '<%= ProductConstant.MODULE_CODE_CRM %>'+ 'Module';

    moduleCell.innerHTML = '<input type=\'text\' name=\'client.moduleCdCrm\' value=\'{$moduleCd};% \' readonly=\'true\' />';

    Please look at the bold italic marked text where I want to assign the value of variable moduleCd. Can someone help me resolve this?

    Thanks

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Code:
    moduleCell.innerHTML = '<input type="text" name="client.moduleCdCrm" value="'+moduleCd+'" readonly="true" />';


  •  

    Posting Permissions

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