0
if (control == 'CheckBoxList2') {                  
        <div class='container'>
              <input type='checkpro1'/>0037 : Quinn, Thomas DDS <br/>
              <input type='checkpro2'/>1234 : Sad, Asd <br/>
              <input type='checkpro3'/>QADR2 : Snell, Jason <br/>
              <input type='checkpro4'/>12SPAC : Space, Ken <br/>
              <input type='checkpro5'/>12345 : Test, Hygienist DDS <br />                
       </div></td></tr>
}

It showing red lines in the above code..

I apppend the code in html var but still not working.

if (control == 'CheckBoxList2') { var html_val=" 0037 : Quinn, Thomas DDS
1234 : Sad, Asd
QADR2 : Snell, Jason
12SPAC : Space, Ken
12345 : Test, Hygienist DDS
";

                </div>
            } 
3
  • 2
    i guess you want type="checkbox" name="checkproX" Commented Apr 8, 2014 at 7:34
  • 3
    You're adding html code in js, you'll need to wrap this as a string and then append it where you want. Commented Apr 8, 2014 at 7:35
  • I changed type=checkbox but still showing red lines Commented Apr 8, 2014 at 7:47

3 Answers 3

1
if (control == 'CheckBoxList2') {                  
    var html_val = "<div class='container'><input type='checkbox' name='checkpro1'/>0037 : Quinn, Thomas DDS <br/>";
}

Type must be checkbox and name as per your requirement.

Above is the reference code you need to modify as per your requirement.

Append html string in variable and use variable to display the HTML

Sign up to request clarification or add additional context in comments.

Comments

0

You can't use HTML like this way in js. Use like this code

if (control == 'CheckBoxList2') {                  
    var html_val = "<div class='container'><input type='checkpro1'/>0037 : Quinn, Thomas DDS <br/>";              
}

Comments

0

Assuming you want the HTML code inside the control with id='CheckBoxList2'

if (control == 'CheckBoxList2') {                  
        var divHtml='<div class='container'>';
        divHtml+='<input type='checkpro1'/>0037 : Quinn, Thomas DDS <br/>';
        divHtml+='<input type='checkpro2'/>1234 : Sad, Asd <br/>';
        divHtml+='<input type='checkpro3'/>QADR2 : Snell, Jason <br/>';
        divHtml+='<input type='checkpro4'/>12SPAC : Space, Ken <br/>';
        divHtml+='<input type='checkpro5'/>12345 : Test, Hygienist DDS <br />';                
        divHtml+='</div>';
        document.getElementById('CheckBoxList2').innerHTML=divHtml;
}

if you want the HTML code inside another element, say a table cell then you need to reference that element and use innerHTML on that element.

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.