Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    appendChild Problemin IE

    HI All,
    i am new to javascript so may be doing something wrong.i am trying to create dynamic textbox using javascript.
    i developed code in a seperate page and it worked fine but when i merged this code in my project work its not working fine in IE.
    problem seems to be occuring while trying to use appendChild() method.

    below is the code snapshot

    <%@ taglib prefix="s" uri="/struts-tags"%>


    <table>
    <tr>
    <td align="right">
    <b>Challan Preferences</b>
    <br/>
    </td>
    </tr>
    </table>

    <table border="0" cellspacing="0" cellpadding="0" width="100%">


    <script type="text/javascript" language="JavaScript" src="js/DynamicTextBox.js"></script>



    <tr>
    <td>


    <div id="ChallanPreferences" class="yui-navset">
    <ul class="yui-nav">
    <li><a href="#tab1"><em>No of Plates</em></a></li>
    <li class="selected"><a href="#tab2"><em>Plates Types</em></a></li>
    <li><a href="#tab3"><em>Colors</em></a></li>
    <li><a href="#tab4"><em>Machines</em></a></li>

    </ul>
    <div class="yui-content">

    <div id="tab1"></br>Number of plates specify, maximum numbers of plates you can use for any printing job</br>
    You can specify any integer value specifying numbers of plates you can use.</br>
    </br>

    <table width="100%" >

    <tr>

    <td height="5" colspan="6"><img src="images/spacer.gif" alt="" width="8" height="1" border="0"></td>
    </tr>
    <tr >
    <td class="labelBold" id="cstNumber">
    <s:form>
    <input class="inputText" type="Text" size="20" name="noOfPlates" value="">
    <input type="submit" value="Update Plates No">
    </s:form>
    </td>

    </tr>
    <tr>
    <td height="5" colspan="6"><img src="spacer.gif" alt="" width="8" height="1" border="0"></td>

    </tr>
    </table>



    </div>
    <div id="tab2"></br>Plate type specify, maximum numbers of plates you can use for any printing job</br>
    You can specify any integer value specifying numbers of plates you can use.</br>
    </br>

    <table width="100%">

    <tr>

    <td height="5" colspan="6"><img src="images/spacer.gif" alt="" width="8" height="1" border="0"></td>
    </tr>
    <tr >
    <td class="labelBold" id="cstNumber">
    <s:form>
    <input class="inputText" type="Text" size="20" name="newPlateType" id="newPlateType" value="Enter New Plate Type" onclick="clearText()">
    <input type="button" value="Add New Plate Type" onclick="addNewTextBox()">
    </s:form>
    </td>

    </tr>
    <tr>
    <td height="5" colspan="6"><img src="spacer.gif" alt="" width="8" height="1" border="0"></td>

    </tr>
    </table>

    <div id="NewPlateType"></div>

    </div>
    </div>

    </div>
    <script>
    (function() {
    var tabView = new YAHOO.widget.TabView('ChallanPreferences');


    })();
    </script>

    </td>
    </tr>
    </table>

    above page is being used in another page

    <html>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <head>


    <title>BillSmart 1.0</title>




    </head>

    <body id="yahoo-com" class=" yui-skin-sam">


    <table width="750px" border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>

    <td colspan="2"><s:include value="TopPane.jsp"></s:include></td>
    </tr>
    <tr>


    <td width="850px" valign="top" height="500px">

    <s:include value="MyTextCreatingPage.jsp"/>

    </td>

    </tr>
    <tr>
    <td colspan="2"><s:include value="../Frames/Footer.jsp"></s:include></td>
    </tr>
    </table>
    </body>
    </html>




    here is the javascript code
    function addNewTextBox() {
    var type="text";


    //Create an input type dynamically.
    var element = document.createElement("input");
    var breakTag="</br>";

    //Assign different attributes to the element.
    element.setAttribute("type", type);

    element.setAttribute("value", type);

    element.setAttribute("name", type);

    var foo = document.getElementById("NewPlateType");

    //Append the element in page (in span).

    foo.appendChild(element);

    foo.appendChild(breakTag);

    }

    this problemis only coming in IE in others browser its working fine
    IE is displaying following error
    unexpected call to method or property access.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,859
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Validate your code and fix all errors. You can't have the same id for multiple elements.

    PS: welcome to CF.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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