Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

The Server threw an exception

Posted on 2003-11-24
7
Medium Priority
?
1,369 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
[X]
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
  • 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 500 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

722 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