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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Location
    Costa Mesa, CA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Someone please help! Object Expected error...

    I'm not a javascript programmer. I have tested 2 separate colorpicker codes and they both work fine in a plain vanilla html page.

    I have a page that loads a little differently. First the page is an aspx page.

    Code:
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="adv_style_settings.aspx.vb" Inherits="users_adv_style_settings" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Advanced User Options</title>
      
        <script src="../iframe.js" type="text/javascript"></script>
          <script src="202pop.js" type="text/javascript"></script>
        <script type="text/javascript">
            function loadFrm(){
                    if (this.options[this.selectedIndex].value!='0'){
                        document.getElementById('myframe').style.display='block';
                        document.getElementById('myframe').src=this.options[this.selectedIndex].value+'/admin/admin.php?IFLM=&page=dir_style';
                    }
                    else{
                        document.getElementById('myframe').style.display='none';
                    }
                  
                  //document.getElementById('myframe').src='http://'+this.options[this.selectedindex].text;
                return false;
                  // 
            }
        </script>
           
    </head>
    <body>
        <form id="form1" runat="server">
        <div style="background-color:White;">
            <h1>Advanced User - Options.</h1>
            <br />       
            <b>Select your advanced site:</b>
            <asp:DropDownList ID="lstAdvanceSites" runat="server" AutoPostBack="false" />        
            <script type="text/javascript">
               document.getElementById('<%=lstAdvanceSites.ClientID%>').onchange=loadFrm;
            </script>
            <br />
            <b><u>Note:</u></b> When you're done with the options settings. 
            <a href="javascript:window.close();">CLOSE THIS Window</a>
            <br />
            <iframe id="iframe" frameborder="0" marginheight="0" marginwidth="0" name="myframe"
                scrolling="no" style="width: 100%; height: 1000px; display: none;"></iframe>
          
            <br /><br />
            <b><u>Note:</u></b> When you're done with the options settings.
            <a href="javascript:window.close();">CLOSE THIS Window</a>
            <br /><br /><br />
        </div>
        </form>
    </body>
    </html>
    That 2nd line of the script tags for <script src="202pop.js" type="text/javascript"></script>

    loads a little popup color picker. It doesn't pop up, and I get an error that an object is expected in the admin.php file. If you look at the line:
    document.getElementById('myframe').src=this.options[this.selectedIndex].value+'/admin/admin.php?IFLM=&page=dir_style';
    where the middle of the page loads all the html for the page, the reference to dir_style.php contains all the form fields. It is in this dir_style.php file where the call to the color picker happens. This has to be becuase this is where I position the color picker on the page right next to the textbox field that holds the hex code for the color.

    I'm happy to send any good javascript programmer a folder of some files so you can see this. Thanks for the help.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Code:
    <script type="text/javascript">
               document.getElementById('<&#37;=lstAdvanceSites.ClientID%>').onchange=loadFrm;
            </script>
    You try to refer an element before it was actually loaded (the element is bellow the javascript code line and the loading process is sequential, from top to bottom). Nest the statement inside a function and call it onload:
    Code:
    <script type="text/javascript">
    onload=function(){
               document.getElementById('<%=lstAdvanceSites.ClientID%>').onchange=loadFrm;
    }
    </script>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Location
    Costa Mesa, CA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi there,

    Can I please have your email address and send you the files for this? I don't have any problem with the code which you responded to. The drop down box works fine. I'm getting an object expected error in a different file. So would you mind taking a look at this further for me?

    Best Regards,

    Scot King

  • #4
    New to the CF scene
    Join Date
    Oct 2008
    Location
    Costa Mesa, CA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is now resolved. I moved my colopicker line to the same file as the one which calls the picker.


  •  

    Posting Permissions

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