...

View Full Version : Referring Javascript variable in input text value



rashedulhasan
06-23-2009, 11:33 AM
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.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\' [I]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

Spudhead
06-23-2009, 12:51 PM
moduleCell.innerHTML = '<input type="text" name="client.moduleCdCrm" value="'+moduleCd+'" readonly="true" />';



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum