Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 542
  • Last Modified:

Pass back the value to opener window for dialog window!

hello, i have a very important question. I tried long time to fix the problem but unfortunately i can't work so i hope that any people can help me as soon as posible!!

I had done below section with the Window.Open, and its work... but i need to Model means set focus and not allow to go back to opener or parent window before cancel or pass value go.

This is the main page to call pop up window
<html>
<head>
<title>Untitled Document</title>

<script language="javascript">
      function OpenPopUp(){
Mywindow = window.open("popupmenu.htm", "Mywindow", "toolbar=no,location=yes,dicrectories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=475,height=155")
      }
      
</script>

</head>
<body>

<form NAme="myform" method="post">
      <input type="text" name="mytext" >
      <input type="submit" onClick="OpenPopUp()">            
</form>


</body>
</html>


This is the pop up box...... to pass back to main
<html>
<head>
<title>Untitled Document</title>

<script type="text/javascript" language="javascript">
      function updatewindow(){
            opener.document.myform.mytext.value = document.myform.mytext.value

      }
      
</script>
</head>
<body>

<form Name="myform" method="post">
      <input type="text" name="mytext" >
      <input type="submit" onClick="updatewindow()">      
</form>


</body>
</html>



so now i would like to know that if i use Dialog box
            Mywindow = window.showModalDialog("popupmenu.htm", "Mywindow", "dialogWidth: 500px; dialogHeight: 350px; center:yes");
i cannot pass back the value..
any ppl know...
or else any ppl can use Window.Open with Model?????

and i hope that this solution can allow a lot of button to call the window and pass back to each of the text box..
something like Lookup button.......

0
JackieWai
Asked:
JackieWai
3 Solutions
 
devicCommented:
hi JackieWai,

here is HOWTO showModalDialog


============index.html============================
<html>
<head>
<title>Untitled Document</title>
<script>
function OpenPopUp()
{
      return showModalDialog("popupmenu.htm", "Mywindow", "toolbar=no,location=yes,dicrectories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=475,height=155")
}
function run()
{
      document.myform.mytext.value=OpenPopUp();
}    
</script>

</head>
<body>
<form NAme="myform">
    <input type="text" name="mytext" >
    <input type="button" onClick="run()" value=run>          
</form>
</body>
</html>



====================popupmenu.htm==================
<html>
<head>
<title>Untitled Document</title>

<script>
    function updatewindow()
      {
            returnValue = document.myform.mytext.value;
            self.close();
    }
</script>
</script>
</head>
<body>

<form Name="myform">
    <input type="text" name="mytext" >
    <input type="button" onClick="updatewindow()" value="ok">    
</form>


</body>
</html>
0
 
ZontarCommented:
showModalDialog() is MSIE only.

For cross-browser, use window.open() and put

onblur="self.focus();"

in the <body> tag.

Note: I find both methods to be EXTREMELY annoying when I come across sites that use them... but you asked.
0
 
JackieWaiAuthor Commented:
dear Zontar, your method can make it loop until focus... but unfortunately, i cannot type or click button, no have any function
any thanks.... you give me a good idea.

for devic, your method can use...very good.. until i feel very perfect.
but i got 1 problem, after i pass back my data but it auto refresh it until no have all data delete..

this should be very easy..
but i not sure is this because the method using POst
but i delete it also same..
any thing can make it not delete it..?
0
 
NetGrooveCommented:
Use this way of calling your modal window:

   Mywindow = window.showModalDialog("popupmenu.htm", window, "dialogWidth: 500px; dialogHeight: 350px; center:yes");

And the popup can access its opener window and openers objects trough this reference:
    window.dialogArguments

Here is the description:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/showmodaldialog.asp


Good luck,
NetGRoove

0
 
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: devic {http:#9761240} & Zontar {http:#9761933} & NetGroove {http:#9762383}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now