469,935 Members | 1,924 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,935 developers. It's quick & easy.

How to load drop down list vaules from the main page to popup window?

Hi,
Functionality is like when pressing 'CTRL+click' on drop down list in the main jsp page, a popup window appears with a list box contains all the values of the drop down clicked on the main page. But some times when we expand the drop down and press "CTRL+click" on any of the options in the main jsp, values are not getting populated in the popup window List box. Is any other options to load values from main jsp to popup jsp fle?

Pls see the code used in the popup window to list the values:

Expand|Select|Wrap|Line Numbers
  1. <script>
  2.     function populateList() {     
  3.      var size = eval("window.opener.document.forms[0]."+elementName+".length");
  4.      for(var i = 0;i<Number(size);i++){
  5.      var txt = eval("window.opener.document.forms[0]."+elementName+".options["+i+"].innerText");
  6.      var val = eval("window.opener.document.forms[0]."+elementName+".options["+i+"].value");
  7.      var newOption = new Option(txt, val, false, false);
  8.      document.forms[0].listBox.options[i] = newOption;
  9.      }
  10.     }
  11.  
  12.     </script>
  13.   <body onload = "javascript:populateList();">
Feb 13 '07 #1
1 6553
acoder
16,027 Expert Mod 8TB
Don't use eval.
Try this instead:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2.     function populateList() {
  3.      var size = window.opener.document.forms[0][elementName].length;
  4.      for(var i = 0;i<size;i++) {
  5.      var txt = window.opener.document.forms[0][elementName].options[i].text;
  6.      var val = window.opener.document.forms[0][elementName].options[i].value;
  7.      var newOption = new Option(txt, val, false, false);
  8.      document.forms[0].listBox.options[i] = newOption;
  9.      }
  10.     }
  11. </script>
  12. <body onload = "javascript:populateList();">
I'm assuming you've set the elementName somewhere. If not, that should be the problem.
Feb 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Tom Ewall | last post: by
9 posts views Thread by John Kirksey | last post: by
7 posts views Thread by Jeremy | last post: by
5 posts views Thread by Vigneshwar Pilli via DotNetMonster.com | last post: by
4 posts views Thread by teknoshock | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.