Google Answers Logo
View Question
 
Q: Javascript pop-up and refresh underlying page ( Answered 4 out of 5 stars,   0 Comments )
Question  
Subject: Javascript pop-up and refresh underlying page
Category: Computers > Programming
Asked by: kees-ga
List Price: $20.00
Posted: 17 Sep 2002 08:38 PDT
Expires: 17 Oct 2002 08:38 PDT
Question ID: 65994
Hello there readers!

I am trying to make the following thing work:
I have a page on which i have a fixed arrival and departure date.
At the moment i want to change my dates on this page a new window
pops-up on which i fill in my new arrival and departure dates.
At the moment i submit the new values in this popup i want to refresh
the undelying page (from which i called the pop-up).
How do i do this?

to see the example pages that i mean click here first: (to set a
cookie with dates):
http://new.hotels.nl/cgi-bin/searchav.pl?plaats=Amsterdam&numpers=2&arrday=17&arrmonth=9&arryear=2002&depday=20&depmonth=9&depyear=2002

then click on this link: (to go to a working hotel page)
http://new.hotels.nl/amsterdam/novotel/

on this page you can click on 1 of the arrival or departure links in
the room window.


The thing that i am trying to solve is that after clicking submit in
the pop-up the underlying page has got to be refreshed......

Thanks for your input guys / gals !

Kees Eldering
Answer  
Subject: Re: Javascript pop-up and refresh underlying page
Answered By: joseleon-ga on 17 Sep 2002 13:46 PDT
Rated:4 out of 5 stars
 
Hello, kees!:
  I think this is what you are looking for, here is the sample code,
be careful when copying and pasting with word wrapping:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_openBrWindow(divname,winName,features,curvalue) { //v2.0
  w=window.open('',winName,features);
  w.document.write('<form name="form1" method="post" action="">');
  w.document.write('<input type="text" name="textfield"
value="'+curvalue+'"><br>');
  w.document.write('<input type="button" value="Press here"
onClick="window.opener.document.getElementById(\''+divname+'\').innerHTML=form1.textfield.value;
window.close();">');
  w.document.write('</form>');  
  w.document.close();  
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="400" border="2" cellspacing="0" cellpadding="0">
  <tr>
    <td><a href="javascript:MM_openBrWindow('text1','popup','width=200,height=100',document.getElementById('text1').innerHTML)">Arrival</a>
    </td>
    <td><div id="text1">This is a text to test</div></td>
  </tr>
  <tr>
    <td><a href="javascript:MM_openBrWindow('text2','popup','width=200,height=100',document.getElementById('text2').innerHTML)">Departure</a></td>
    <td><div id="text2">This is a second text to test</div></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

How it works?, it's really easy, the links call a javacript function
called MM_openBrWindow:

function MM_openBrWindow(divname,winName,features,curvalue) { //v2.0
  w=window.open('',winName,features);
  w.document.write('<form name="form1" method="post" action="">');
  w.document.write('<input type="text" name="textfield"
value="'+curvalue+'"><br>');
  w.document.write('<input type="button" value="Press here"
onClick="window.opener.document.getElementById(\''+divname+'\').innerHTML=form1.textfield.value;
window.close();">');
  w.document.write('</form>');  
  w.document.close();  
}

The first parameter is the name of the div tag which holds the text to
be edited, the second is the name of the new window, the third, the
features of the window (border, status, etc) and the fourth is the
current value for the div tag.
This function, creates a new window and writes a simple form inside
it, with an input field and a button. When the button is pressed, it
changes the div.innerHTML property to be the same as the textfield and
closes the window.

I think you can easily adapt it to fit your needs, but don't hesitate
to request for any help! ;-)

I have tested it on IE and Mozilla, and it works well, but if you want
something else just ask, we are here to help you-

Regards.
kees-ga rated this answer:4 out of 5 stars
Thanks a lot joseleon-ga, works perfectly !

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy