Solved

The Server threw an exception

Posted on 2003-11-24
7
1,357 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

762 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

23 Experts available now in Live!

Get 1:1 Help Now