...

View Full Version : Someone please help! Object Expected error...



goodlinks
10-11-2008, 06:51 AM
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.


<%@ 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. :D

Kor
10-11-2008, 12:24 PM
<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:


<script type="text/javascript">
onload=function(){
document.getElementById('<%=lstAdvanceSites.ClientID%>').onchange=loadFrm;
}
</script>

goodlinks
10-12-2008, 12:35 AM
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

goodlinks
10-12-2008, 05:23 AM
This is now resolved. I moved my colopicker line to the same file as the one which calls the picker.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum