Solved

Pass back the value to opener window for dialog window!

Posted on 2003-11-16
6
525 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now