Connecting Tech Pros Worldwide Help | Site Map

Window popUp

Member
 
Join Date: Apr 2008
Posts: 66
#1: Aug 27 '08
Hi everyone.

I have problem with this function javascript:

Expand|Select|Wrap|Line Numbers
  1. var popup = null;
  2.  
  3. function OpenPopup(fld, tbl, col, w, h)
  4. {
  5.   var pw = Math.floor((screen.width - w) / 2);
  6.   var ph = Math.floor((screen.height - h) / 2);
  7.  
  8.   if (!popup || popup.closed) popup = window.open
  9.  
  10. ("popUp.htm?f=" + fld + "&t=" + tbl + "&c=" + col, "sel",
  11.               "width=" + w + ",height=" + h + ", top=" + ph + ",left=" + pw);
  12.  
  13.   if (popup) popup.focus();
  14. }
If I select value TEST in the select name="type", the function open parent page popup.htm in window popup; I select value and close window popup.

If I select again value TEST in the select name="type", the function NOT open parent page popup.htm in window popup.

Any suggestion ?

Code page.htm:

Expand|Select|Wrap|Line Numbers
  1. <select size="1" name="type" onchange="OpenPopup(this.options[this.selectedIndex].value, 'tbl', 'elm', 400, 200)">
  2.  
  3.   <option value="TEST">TEST</option>
  4.   <option value="TEST_2">TEST_2</option>
  5.  
  6. </select>
  7.  
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,128
#2: Aug 27 '08

re: Window popUp


onchange is fired when the value is really changed ... when you always want to open the popup then you may use onclick ... so selecting the same value again instead of a different one prevents the onchange from firing. you could even try to add onclick-handlers directly to the options itself ...

kind regards
Reply


Similar JavaScript / Ajax / DHTML bytes