Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

The Server threw an exception

Posted on 2003-11-24
7
1,362 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

860 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