Page 1 of 1

DHTML replacing <input type="text" with value

Posted: Wed Apr 25, 2012 2:52 am
by wvoyance
I have an HTML
<tr>
<td class="main">Products Name:</td>
<td class="main" id=pn0><img src="/catalog/includes/languages/english/images/icon.gif" border="0" alt="English" title="English">&nbsp;<input type="text" name="products_name[1]" /></td>
</tr>

which I would like to replace using

document.getElementById("pn0").innerHTML='<img src="/catalog/includes/languages/english/images/icon.gif" border="0" alt="English" title="English">&nbsp;<input type="text" name="products_name[1] value="title" />';


to give the input field an initial value. But it seems does not work. The value="title" simply do not appear.
Why? How should I do?

Re: DHTML replacing <input type="text" with value

Posted: Wed Apr 25, 2012 5:59 am
by twinedev
you do not have the closing quote for the name attribute. Any reason why not just give the input an id and then do:

document.getElementById('inputID').value = "title";

-Greg