Solved

The Server threw an exception

Posted on 2003-11-24
7
1,358 Views
Last Modified: 2007-12-19
Hi Guys,

    I have a parent and child window. From the child window trying to add a item to the SELECT OPTION placed in the parent window, its giving the err "The Server threw an exception". Any idea would be appreciated.

here is the code,

window.opener.ReEntry.skills.options[ window.opener.ReEntry.skills.length + 1 ]=new Option(data.value);

window.opener.ReEntry.skills - parent widow's select option.
data.value - text input value in the child window

Best Regards,
Siva
0
Comment
Question by:ksivananth
  • 3
  • 3
7 Comments
 
LVL 10

Expert Comment

by:NetGroove
ID: 9810037
Hello Siva,

this is a standard problem that you try to fetch memory in a popup window for object referenced in parent window.
The new Option() reserves memory for the options.

Second problem is that your form is child of document, not of window.

Better is to do it like this:

  popform = document.forms[0];
  opt = window.opener.document.ReEntry.skills.options;
  newOpt = opt.length;
  opt[newOpt].text =  popforn.data.value;
  opt[newOpt].value =  popforn.data.value;


Good luck,
NetGroove


0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 125 total points
ID: 9810378
I ran into this problem a while back where I tried to manipulate a select list on a parent window via a function on the child. It worked fine on NS but threw this error with IE. The way that I got around it is as follows:

1) Move the function from the child window to the parent window
2) Change the way that you call the function to something like this:

window.opener.yourFunction(strParameter);

What will happen now is the that the select list will be manipulated by a function on the same page, and all will work well.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9810422
So, on the parent window, create a function called addItem()

function addItem(strValue,strText){
   var objSel = document.forms['ReEntry'].elements['.skills'];
   objSel[objSel.length].value =  strValue;
   objSel[objSel.length].text =  strText;
}


and then you can call it from you child like this:

window.opener.addItem('Excel','Microsoft Excel');

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Expert Comment

by:NetGroove
ID: 9810752
Sorry, my version contained several typos.

Here a tested version:

<html>
<head>
<script>
function addOpt(){
 popform = document.forms[0];
 opt = window.opener.document.ReEntry.skills.options;
 newOpt = opt.length;
 opt.length = newOpt+1;
 opt[newOpt].text = popform.data.value;
 opt[newOpt].value = popform.data.value;
}
</script>
</head>
<body>
<form>
<input type=text name="data">
<input type=button value=Add onClick="addOpt()">
</form>
</body>
</html>


And the parent form is something like this:
<html>
<body>
<form name=ReEntry>
<select name=skills>
<option>One
</select>
<input type=button value=Add onClick="open('popsel.htm','pop','height=200,width=300')">
</form>
</body>
</html>


0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9817950
Hello Siva,

is your problem now solved?
Do you need more help?

0
 
LVL 26

Author Comment

by:ksivananth
ID: 9822540
Hi Guys,

    Thank ypu so much for your helps.

I solved the issues using the Comment from fritz_the_blank on
Date: 11/24/2003 05:50AM PST.

    Sorry NetGroove, I tried the way u suggested before posting this question but it doesn't work. Yo are saying it works for you, probably you would have tested in Netscape, try it in IE, you'll get the same err.

    So I am giving the points to fritz_the_blank!

Thanks & Regards,
Siva

0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9824495
Glad to have helped,

FtB
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now