Dynamically create checkbox based on the output in the responseText from server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarega
    New Member
    • Oct 2008
    • 82

    #16
    attachEvent itself worked, thanks
    does the
    Code:
    var div=document.getElementById("div_id");
    var example=document.createElement('input');
    example.type='submit';
    example.name='submit';
    example.value='submit;
    div.appendChild(example);
    not work in IE because its working in mozilla but not in IE.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #17
      I'm not sure if IE creates attributes via element.value = "value"; , you still could try the DOM methods setAttribute() or createAttribute () (at least they work for me)

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #18
        You have an end quote missing on line 5. Always check the error console.

        Comment

        • sarega
          New Member
          • Oct 2008
          • 82

          #19
          actually the end quote is not the problem, I removed the element.value=v alue but still its not working

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #20
            Well, it would've been a problem if it was missing. When you say it's not working, what exactly do you mean? Does it not show up? Does it not submit the form when clicked?

            Comment

            • sarega
              New Member
              • Oct 2008
              • 82

              #21
              It does not submit the form when clicked

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #22
                Have you set the action of the form and is the div inside a form?

                Comment

                • sarega
                  New Member
                  • Oct 2008
                  • 82

                  #23
                  yes I have, its working for mozilla but not in IE

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #24
                    Post the HTML code or at least some test code demonstrating the problem.

                    Comment

                    • sarega
                      New Member
                      • Oct 2008
                      • 82

                      #25
                      Code:
                      var div=document.getElementById("div_id");
                      var example=document.createElement('input');
                      example.type='submit';
                      example.name='submit';
                      example.value='submit';
                      div.appendChild(example);

                      Comment

                      • sarega
                        New Member
                        • Oct 2008
                        • 82

                        #26
                        Code:
                        var test=document.getElementById('mydiv');
                        	var br=document.createElement('br');
                        	test.appendChild(br);
                        	var check=document.createElement('input');
                        
                        	check.type='checkbox';
                        	[URL="http://check.id/"]check.id[/URL]='check';
                        	[URL="http://check.name/"]check.name[/URL]='Testmode';
                        [B]	check.value='on';[/B]
                        
                        	var text='Testmode';
                        	test.appendChild(check);
                        	test.appendChild(document.createTextNode(text));	
                        	var bre=document.createElement('br');
                        	test.appendChild(bre);
                        	var brea=document.createElement('br');
                        
                        	test.appendChild(brea);
                        	var submit=document.createElement('input');
                        	submit.type='submit';
                        	[URL="http://submit.name/"]submit.name[/URL]='submit';
                        	[URL="http://submit.id/"]submit.id[/URL]='submit';
                        
                        	submit.value='submit';
                        	test.appendChild(submit);

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #27
                          That's the JavaScript code. We already have that. What about the HTML code and where and how this JavaScript code is called? You could, of course, just post a link instead if possible.

                          Comment

                          • sarega
                            New Member
                            • Oct 2008
                            • 82

                            #28
                            Am calling this function as soon as the response is returned form the server.
                            But not able to figure out why its not working in IE.

                            Comment

                            • acoder
                              Recognized Expert MVP
                              • Nov 2006
                              • 16032

                              #29
                              You still haven't posted the HTML code.

                              Comment

                              • sarega
                                New Member
                                • Oct 2008
                                • 82

                                #30
                                Code:
                                <input id="chkbx" type="checkbox" value="on" name="example"/>
                                Change the color?
                                <br/>
                                <br/>
                                Colors
                                <br/>
                                <br/>
                                <input id="red" type="checkbox" name="colors[]" value="red"/>
                                red
                                <br/>
                                <input id="blue" type="checkbox" name="colors[]" value="blue"/>
                                blue
                                <br/>
                                <input id="green" type="checkbox" name="colors[]" value="green"/>
                                green
                                <br/>
                                </div>
                                <br/>
                                <input id="check" type="checkbox" name="Testmode" value="on"/>
                                Testmode
                                <br/>
                                <br/>
                                <input id="submit" type="submit" name="submit" value="submit"/>
                                <br/>

                                Comment

                                Working...