Results 1 to 2 of 2

Thread: Inserting Forms tags into Div - Runtime Exception Error

  1. #1
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Inserting Forms tags into Div - Runtime Exception Error

    When I try inserting a "<form>" tag inside the "div" tag. I get "Unknown runtime exception error.

    <div id="a"></div>

    document.getElementById("a").innerHTML = "<form id='x'> </form>";

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there maheshexp,

    it works without error for me.

    You might like to try using the DOM instead...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript">
    window.onload=function() {
       frm=document.createElement('form');
       frm.setAttribute('id','x');
    
       inp=document.createElement('input');
       inp.setAttribute('value','maheshexp');
       frm.appendChild(inp);
    
       document.getElementById("a").appendChild(frm);
    
       alert('form id="'+document.forms[0].id+'"');
       alert('type="'+document.forms[0][0].type+'"');
       alert('value="'+document.forms[0][0].value+'"')
     }
    </script>
    
    </head>
    <body>
    
    <div id="a"></div>
    
    </body>
    </html>
    coothead

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •