DHTML replacing <input type="text" with value

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

DHTML replacing <input type="text" with value

Post 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?
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

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

Post 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
Post Reply