Solved

Pass back the value to opener window for dialog window!

Posted on 2003-11-16
6
540 Views
Last Modified: 2008-02-26
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
Comment
Question by:JackieWai
[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
6 Comments
 
LVL 25

Accepted Solution

by:
devic earned 34 total points
ID: 9761240
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
 
LVL 11

Assisted Solution

by:Zontar
Zontar earned 33 total points
ID: 9761933
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
 

Author Comment

by:JackieWai
ID: 9762231
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
 
LVL 10

Assisted Solution

by:NetGroove
NetGroove earned 33 total points
ID: 9762383
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10382698
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

636 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