SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Problem in IE, works ok in Firefox..

    Hi there,

    Im am not very good at all when it comes to using javascript, so i got the code for my website from a code site for a partiqular effect.

    If you run the following code in firefox, and click on the button at the bottom saying "Add Photo", you will see what is meant to happen, if you then went into internet explorer and did the same thing it does nothing and a says an Invalid Argument error.

    Can someone please help me...im getting desperate and its very important i get this right.

    here is the code

    PHP Code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

    "http://www.w3.org/TR/html4/loose.dtd"
    >

    <
    html>

    <
    head>

    <
    script language="javascript">
    var 
    items=0;
    function 
    AddItem() {
      
    div=document.getElementById("items");
      
    button=document.getElementById("add");
      
    items++;
      
    newitem="<b>Image " items ": </b>";
      
    newitem+="<input type=\"text\" name=\"p_strUpload"items;
      
    newitem+="\" size=\"40\">";
      
    newitem+="<a href=\"javascript:mcImageManager.open('add','p_strUpload"items +"');\"><br /><img src=\"../images/menu/browse.gif\" alt=\"?\" border=0></a><br><br>";
      
    newnode=document.createElement("span");
      
    newnode.innerHTML=newitem;
      
    div.insertBefore(newnode,button);
    }
    </script>

    <script language="JavaScript" type="text/javascript">

    <!-- Hide script

        function deleteItem(path) {

            if (confirm ('Are you sure you want to delete this Product?')) {

                document.location = path;

            }

        }

    // -->

    </script>

    <style type="text/css">@import url("/format.css");</style>

    <script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
    <script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/mcimagemanager.js"></script>
    <script language="javascript" type="text/javascript">
    tinyMCE.init({
            mode : "textareas",
            theme : "advanced",
            plugins : "table,advhr,advimage,advlink,preview,zoom,contextmenu,paste,fullscreen",
            theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator",
            theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator",
            theme_advanced_buttons3_add_before : "tablecontrols,separator",
            theme_advanced_buttons3_add : "advhr,fullscreen",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "center",
            theme_advanced_path_location : "bottom",
            content_css : "/format.css",
            plugin_insertdate_dateFormat : "%Y-%m-%d",
            extended_valid_elements : "hr[class|width|size|noshade]",
            external_link_list_url : "example_link_list.js",
            external_image_list_url : "example_image_list.js",
            flash_external_list_url : "example_flash_list.js",
             file_browser_callback : "mcImageManager.filebrowserCallBack",
            paste_use_dialog : false,
            theme_advanced_resizing : true,
            theme_advanced_resize_horizontal : false,
            theme_advanced_link_targets : "_something=My somthing;_something2=My somthing2;_something3=My somthing3;"

    });


        function fileBrowserCallBack(field_name, url, type, win) {
            // This is where you insert your custom filebrowser logic
            alert("Filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);

            // Insert new URL, this would normaly be done in a popup
            win.document.forms[0].elements[field_name].value = "someurl.htm";
        }

    </script>

    <title>Phantom Management Administration Section</title>



    <style type="text/css">

    <!--

    #container { position: absolute; padding: 0px; margin: 0px; text-align: left; width: 800px; left: 50%; margin-left: -400px; border: 1px #30559C solid;}

    #header { position: relative;width: 800px; height: 52px; text-align: left; overflow: hidden;background-repeat: no-repeat; background-image: URL(../images/structure/header.gif);}

    #body { position: relative; text-align: center;  margin: 0px; padding: 0px; width: 800px;}

    .thumbnail
    {
        float: left;
        width: 130px;
        margin: 0px;
        padding: 0px;
    }

    -->

    </style></head>

    <body>
    <div id='container'>

        <div id='header'>

        </div>
        <div id='body'>
            <div align='center'>
            <div>Welcome Christopher to the Phantom Management Administration Section.&nbsp;<br>
            Please use the navigation below to access and edit all of the sections of the website.</div>
            <table class="title">
                <tr>
                    <td>
                        <img src="../images/menu/productdetails.gif" alt="?" border=0>
                    </td>
                    <td align='center'>
                        <a href="../index2.php"><img src="../images/menu/back.gif" alt="?" border=0><br>Back</a>
                    </td>
                </tr>
            <table class="admin_form">
                <tr align='center'>
                    <td>
                    <a href="index.php?mode=view"><img src="../images/menu/products.gif" alt="?" border=0><br>View Male Models</a>
                    </td>

                <td>
                    <a href="index.php?mode=add"><img src="../images/menu/addnew.gif" alt="?" border=0><br>Add Male Model</a>
                    </td>
                </tr>
            </table>
            </div>

    <br>
    <form name="add" method="post" action="index.php?mode=update">

        <div align="center">

    <input type="hidden" name="strID" size="40" value="1">
    <table name='contenttable' class="title">
        <tr>
            <td colspan="3">
                 <h1>Edit - Caucasian Male</h1>
            </td>
        </tr>

    </table>
    <table name='contenttable' class='admin_form'>
        <tr>
            <td rowspan="10" colspan="2"  width='50%' align="center">
                <input type="hidden" name="strHeadshot" value="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/headshot.jpg" size="40">
                <img src="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/headshot.jpg" alt="?" border=0><br /><br>
                <a href="javascript:mcImageManager.open('add','strHeadshot');"><img src="../images/menu/update.gif" alt="?" border=0></a>
            </td>
        </tr>
        <tr align='right'><td>Name :</br><input type="text" name="strName" size="20" value="Oli Pettigrews"></td></tr>
        <tr align='right'><td>Race :<input type="text" name="strRace" size="20" value="caucasian"></td></tr>
        <tr align='right'><td>Eyes :<input type="text" name="strEyes" size="20" value="Green/Haze"></td></tr>
        <tr align='right'><td>Hair Colour :<input type="text" name="strHair" size="20" value="Dark Brown"></td></tr>
        <tr align='right'><td>Height :<input type="text" name="strHeight" size="20" value="180"></td></tr>
        <tr align='right'><td>Chest :<input type="text" name="strChest" size="20" value="38"></td></tr>
        <tr align='right'><td>Waist :<input type="text" name="strWaist" size="20" value="32"></td></tr>
        <tr align='right'><td>Collar :<input type="text" name="strCollar" size="20" value="15.5"></td></tr>
        <tr align='right'><td>Shoe :<input type="text" name="strShoe" size="20" value="44.5"></td></tr>
    </table>

    <br>

    <table name='contenttable' class="title">
        <tr>
            <td colspan="3">
                 <h1>Portfolio Pictures</h1>
            </td>
        </tr>
    </table>

    <table class='admin_form'>
        <tr>
            <td align='center'>
            <div class="thumbnail">
                <input type="hidden" name="u_strImage110" value="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/5.jpg" size="40">
                <img width="120" src="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/5.jpg" alt="?" border=1><a href="javascript:mcImageManager.open('add','u_strImage110');"><img src="../images/menu/browse.gif" alt="?" border=0></a><br />
                <input type="checkbox" name="d_delete110" value="110">Delete
            </div>
            <div class="thumbnail">
                <input type="hidden" name="u_strImage102" value="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/1.jpg" size="40">
                <img width="120" src="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/1.jpg" alt="?" border=1><a href="javascript:mcImageManager.open('add','u_strImage102');"><img src="../images/menu/browse.gif" alt="?" border=0></a><br />
                <input type="checkbox" name="d_delete102" value="102">Delete
            </div>
            <div class="thumbnail">
                <input type="hidden" name="u_strImage103" value="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/2.jpg" size="40">
                <img width="120" src="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/2.jpg" alt="?" border=1><a href="javascript:mcImageManager.open('add','u_strImage103');"><img src="../images/menu/browse.gif" alt="?" border=0></a><br />
                <input type="checkbox" name="d_delete103" value="103">Delete
            </div>
            <div class="thumbnail">
                <input type="hidden" name="u_strImage107" value="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/3.jpg" size="40">
                <img width="120" src="http://www.invisiblewebdesign.co.uk/phantom/images/models/MaleCaucasian/olipettigrew/3.jpg" alt="?" border=1><a href="javascript:mcImageManager.open('add','u_strImage107');"><img src="../images/menu/browse.gif" alt="?" border=0></a><br />
                <input type="checkbox" name="d_delete107" value="107">Delete
            </div>
            </td>
        </tr>
    </table>

    <form name="form1">
    <div ID="items">
    <input type="button" value="Add Photo"
    onClick="AddItem();" ID="add">
    </div>
    </form>


    <table name='contenttable' class="title">
        <tr><td align="center"><input name="cmdAdd" type="submit" value="Save"></td></tr>
    </table>

    </form>

        </div>
        <br><br>
    </div>
    </body>
    </html> 

  2. #2
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is nobody around to help??

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the code that i tried to modify and it works in both ff and ie, but i do not know what i did to break my code ??

    Please can someone check my javascript at the top?

    PHP Code:
    <html>
    <
    head>
    <
    title>Adding elements to a form</title>
    <
    script language="javascript">
    var 
    items=1;
    function 
    AddItem() {
      
    div=document.getElementById("items");
      
    button=document.getElementById("add");
      
    items++;
      
    newitem="<b>Item " items ": </b>";
      
    newitem+="<input type=\"text\" name=\"item" items;
      
    newitem+="\" size=\"45\"><br>";
      
    newnode=document.createElement("span");
      
    newnode.innerHTML=newitem;
      
    div.insertBefore(newnode,button);
    }
    </script>
    </head>
    <body>
    <h1>Adding Form Elements</h1>
    <p>The form below allows you to add elements dynamically.</p>
    <hr>
    <form name="form1">
    <div ID="items">
    <b>Item 1:</b>
    <input type="text" name="item1" size="45">
    <br>
    <input type="button" value="Add an Item"
    onClick="AddItem();" ID="add">
    </div>
    </form>
    </body>
    </html> 

  4. #4
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone....Bump*


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
  •