TLN_CANADA
asked on
Opening Popup with values sent in javascript
Hi all,
I have a page like this setup with a menu where users can select different exercise times. If the user clicks the first link I want it to send a value of 40, the second link a value of 30 when it opens a pop up page.
The initial value of the pop up (child) page is set here in the pop page code:
Can someone show me how to create a pop up page that sends the value in this way?
Thanks very much,
D
I have a page like this setup with a menu where users can select different exercise times. If the user clicks the first link I want it to send a value of 40, the second link a value of 30 when it opens a pop up page.
<div class="col_1 firstcolumn">
<a href="#" >Standard </br>(40 Minutes) </br> (5 minute intervals)</a>
</div>
<div class="col_1">
<a href="#" >30 Min </br>(30 Minutes) </br> (5 minute intervals)</a>
</div>
The initial value of the pop up (child) page is set here in the pop page code:
<input type = "text" id = "Minutes" value = "40" readonly="readonly">
Can someone show me how to create a pop up page that sends the value in this way?
Thanks very much,
D
ASKER
Thanks, I have not setup the popup yet. How should I do it so it passes the values like this? The popup page is called mednow2.htm
ASKER
I want both of the links to open the same popup page, just with the different value.
So by pop-up you mean a new page?
ASKER
Yes, I want it to pop-up in a new window (page)
Try this:
<div class="col_1 firstcolumn">
<a href="popup.php?min=40" target="_blank">Standard </br>(40 Minutes) </br> (5 minute intervals)</</div>
<div class="col_1">
<a href="popup.php?min=30" target="_blank">30 Min </br>(30 Minutes) </br> (5 minute intervals)</a>
</div>
In the popup:
<?php
if (isset($_GET['min']) $$ is_int($_GET['min'])){
$min = $_GET['min'];
}else{
$min = 40;
}
?>
<input type = "text" id = "Minutes" value = "<?php echo $min; ?>" readonly="readonly">
<div class="col_1 firstcolumn">
<a href="popup.php?min=40" target="_blank">Standard </br>(40 Minutes) </br> (5 minute intervals)</</div>
<div class="col_1">
<a href="popup.php?min=30" target="_blank">30 Min </br>(30 Minutes) </br> (5 minute intervals)</a>
</div>
In the popup:
<?php
if (isset($_GET['min']) $$ is_int($_GET['min'])){
$min = $_GET['min'];
}else{
$min = 40;
}
?>
<input type = "text" id = "Minutes" value = "<?php echo $min; ?>" readonly="readonly">
ASKER
Thank you so much Marco! A couple of small changes this to if it's okay. When sending the values I would like to send the minute intervals also so should it look like this:
Also for the child page if this page is not being opened by the parent page I would like this field
to have a default value of 25.
<a href="popup.php?min=40int=5" target="_blank">Standard </br>(40 Minutes) </br> (5 minute intervals)</</div>
Also for the child page if this page is not being opened by the parent page I would like this field
<input type = "text" id = "Minutes" value = "<?php echo $min; ?>" readonly="readonly">
to have a default value of 25.
For the first problem do this:
Add an ampersand to separate parameters;
fFor the second question, I'm not sure to understand what you want: can you be more clear, please?
<a href="popup.php?min=40&int=5" target="_blank">Standard </br>(40 Minutes) </br> (5 minute intervals)</</div>
Add an ampersand to separate parameters;
fFor the second question, I'm not sure to understand what you want: can you be more clear, please?
ASKER
Oh it's okay, I see you have set the default value already :)
It's giving an error on line 2 though on the child page, here's what I have at the start
and the error:
Parse error: syntax error, unexpected '$' in /home/clear555/public_html /mednowphp .php on line 2
It's giving an error on line 2 though on the child page, here's what I have at the start
<?php
if (isset($_GET['min']) $$ is_int($_GET['min'])){
$min = $_GET['min'];
}else{
$min = 40;
}
if (isset($_GET['int']) $$ is_int($_GET['int'])){
$min = $_GET['int'];
}else{
$min = 05;
}
?>
and the error:
Parse error: syntax error, unexpected '$' in /home/clear555/public_html
Ooops! Replace the two $$ with two ampersand &&:
Sorry, what time is it for you?
<?php
if (isset($_GET['min']) && is_int($_GET['min'])){
$min = $_GET['min'];
}else{
$min = 40;
}
if (isset($_GET['int']) && is_int($_GET['int'])){
$min = $_GET['int'];
}else{
$min = 05;
}
?>
Sorry, what time is it for you?
ASKER
It's late here, after 12 at night :) It isn't giving an error now but when I open the child page it is not displaying the initial values correctly. Here is what I have, am I doing something wrong here:
Top of the page:
Top of the page:
<?php
if (isset($_GET['min']) && is_int($_GET['min'])){
$min = $_GET['min'];
}else{
$min = 40;
}
if (isset($_GET['int']) && is_int($_GET['int'])){
$min = $_GET['int'];
}else{
$min = 05;
}
?>
<input type = "text" id = "Minutes" value = "<?php echo $min; ?>" readonly="readonly">
<input type = "text" id = "Seconds" value = "00" readonly="readonly">
<input type = "text" id = "Interval" value = "<?php echo $int; ?>" readonly="readonly">
In the first block of code you're assigning values always to $min variable: first you assing it the value of $_GET['min'] and then you assign it the value of $_GET['int']:
Now it should work.
<?php
if (isset($_GET['min']) && is_int($_GET['min'])){
$min = $_GET['min'];
}else{
$min = 40;
}
if (isset($_GET['int']) && is_int($_GET['int'])){
$int = $_GET['int'];
}else{
$int = 05;
}
?>
Now it should work.
ASKER
Yes, it does display correctly now when I load the page but when I try to pass the values from the parent page to the child page the values do not pass at all and it just displays the default ones. Here is how it looks on the parent page:
<div class="col_1 firstcolumn">
<a href="http://www.clear.com/mednowphp.php?min=22&int=65" target="_blank">Standard </br>(40 Minutes) </br> (5 minute intervals)</</div>
</div>
In the url on the child page it looks correct:
http://www.clear.com/mednowphp.php?min=22&int=65
Any ideas what's going on?
<div class="col_1 firstcolumn">
<a href="http://www.clear.com/mednowphp.php?min=22&int=65" target="_blank">Standard </br>(40 Minutes) </br> (5 minute intervals)</</div>
</div>
In the url on the child page it looks correct:
http://www.clear.com/mednowphp.php?min=22&int=65
Any ideas what's going on?
ASKER
Would it have another to do with the form on the child page. I've tried both the post and get on it but neither work.. .
<form id="form2" name="form2" method="post" action="">
<input type = "text" id = "Minutes" value = "<?php echo $min; ?>" readonly="readonly">
<input type = "text" id = "Seconds" value = "00" readonly="readonly">
<input type = "text" id = "Interval" value = "<?php echo $int; ?>" readonly="readonly">
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much! It's working perfectly now!
One way is here that uses link's title and jquery:
Open in new window