0

I have written this javascript code

document.getElementById('placeForTitle').innerHTML=
"<div class='postAdLabelnTextboxSelTitle'>
       <div class='post-ad-label'>Select Title</div>
       <div class='selectTitleContain'>
           <input name='selctedTitle' type='radio' id='tit1_1' value='"+title1_1+"' required />
           <label for='tit1_1'>"+title1_1+"</label>
           <br />
           <input name='selctedTitle' type='radio' id='tit1_2' value='"+title1_2+"' required />
           <label for='tit1_2'>"+title1_2+"</label><
       /div>
</div>";

but it is not work and due to this other javascript function is also not working. I tried different combinations but not working.

3
  • document.getElementById('placeForTitle').innerHTML="<div class='postAdLabelnTextboxSelTitle'><div class='post-ad-label'>Select Title</div><div class='selectTitleContain'> <input name='selctedTitle' type='radio' id='tit1_1' value='"+title1_1+"' required /><label for='tit1_1'>"+title1_1+"</label><br /><input name='selctedTitle' type='radio' id='tit1_2' value='"+title1_2+"' required /><label for='tit1_2'>"+title1_2+"</label></div></div>"; Commented Feb 12, 2014 at 10:49
  • above code i m trying.. but not working Commented Feb 12, 2014 at 10:50
  • Pasting code in a comment isn't helping us much. Could you edit your question instead? Commented Feb 12, 2014 at 10:53

4 Answers 4

1

Try this:

document.getElementById('placeForTitle').innerHTML=
"<div class='postAdLabelnTextboxSelTitle'>\
       <div class='post-ad-label'>Select Title</div>\
       <div class='selectTitleContain'>\
           <input name='selctedTitle' type='radio' id='tit1_1' value='"+title1_1+"' required />\
           <label for='tit1_1'>"+title1_1+"</label>\
           <br />\
           <input name='selctedTitle' type='radio' id='tit1_2' value='"+title1_2+"' required />\
           <label for='tit1_2'>"+title1_2+"</label>\
       </div>\
</div>";

or

document.getElementById('placeForTitle').innerHTML=
"<div class='postAdLabelnTextboxSelTitle'>" +
       "<div class='post-ad-label'>Select Title</div>" +
       "<div class='selectTitleContain'>" +
           "<input name='selctedTitle' type='radio' id='tit1_1' value='"+title1_1+"' required />" +
           "<label for='tit1_1'>"+title1_1+"</label>" +
           "<br />" +
           "<input name='selctedTitle' type='radio' id='tit1_2' value='"+title1_2+"' required />" +
           "<label for='tit1_2'>"+title1_2+"</label>" +
       "</div>" +
"</div>";
Sign up to request clarification or add additional context in comments.

Comments

0

You can't have a new line in the middle of a JavaScript string literal.

Comments

0
document.getElementById('placeForTitle').innerHTML="<div class='postAdLabelnTextboxSelTitle'>"
       +"<div class='post-ad-label'>Select Title</div>"
       +"<div class='selectTitleContain'>"
           +"<input name='selctedTitle' type='radio' id='tit1_1' value='"+title1_1+"' required />"
           +"<label for='tit1_1'>"+title1_1+"</label>"
           +"<br />"
           +"<input name='selctedTitle' type='radio' id='tit1_2' value='"+title1_2+"' required />"
           +"<label for='tit1_2'>"+title1_2+"</label></div>"
+"</div>";

Comments

0

try this

document.getElementById('placeForTitle').innerHTML=
"<div class='postAdLabelnTextboxSelTitle'><div class='post-ad-label'>Select Title</div><div class='selectTitleContain'><input name='selctedTitle' type='radio' id='tit1_1' value='"+title1_1+"' required /><label for='tit1_1'>"+title1_1+"</label><br /><input name='selctedTitle' type='radio' id='tit1_2' value='"+title1_2+"' required /><label for='tit1_2'>"+title1_2+"</label></div></div>";

you should not break the innerHTML content.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.