In my webpage i have one textbox(hotel name) and a button.
Suppose if i add value “sun shine” in textbox(hotel name) and click on button , the dynamically generated textbox should also have value “sun shine” in it. I am able to generate dynamic textbox using javascript so far. But the value it takes it just the first word i.e “sun” for eg.
javascript code:
val=document.getElementById("hotel_name").value;
....
newdiv.innerHTML = '<input type=text size=15 id=' + hotel[num] + ' value=' + val + '>;
Any idea on how to go about it.Thanks in advance.
Surround attributes with quotes:
Otherwise the generated HTML will look like:
Only
sunwill be treated as being part ofvalue.shinewill be considered as an (invalid) attribute (as you can already see on how syntax highlighting is applied to this code snippet).That’s the reason why you should always use quotes for attribute values.