| | |
Send variable from javascript to php?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Wasn't sure whether to put this in java or php, so I'm putting it here. I have a bit of java that opens a php page in a popup window, using this code:
So that code opens up "my_form.php" in a pop-up window. But I need to pass a value to that php page. Like with PHP, I could simply say <a href="my_form.php?value=25">Click Here</a>
But is there a way I can pass a variable through that link with the java script I've got?
java Syntax (Toggle Plain Text)
<a href="javascript: void(0) "onclick="window.open ('my_form.php','linkname','height=465, width=400, left=550, top=150, scrollbars=no')">Click Here</a>
So that code opens up "my_form.php" in a pop-up window. But I need to pass a value to that php page. Like with PHP, I could simply say <a href="my_form.php?value=25">Click Here</a>
But is there a way I can pass a variable through that link with the java script I've got?
Try adding ?value=25 on to the window.open function.
I have done something like this previously and it has worked.
javascript Syntax (Toggle Plain Text)
<a href="javascript:void(0);" onclick="window.open ('my_form.php?value=25','linkname','height=465, width=400, left=550, top=150, scrollbars=no')">Click Here</a>
I have done something like this previously and it has worked.
If my post is useful please add to my reputation.
Thanks.
Ajtrichards Web Solutions | http://www.ajtrichards.co.uk
Retenovate | http://www.retenovate.com
Thanks.
Ajtrichards Web Solutions | http://www.ajtrichards.co.uk
Retenovate | http://www.retenovate.com
•
•
•
•
Try adding ?value=25 on to the window.open function.
javascript Syntax (Toggle Plain Text)
<a href="javascript:void(0);" onclick="window.open ('my_form.php?value=25','linkname','height=465, width=400, left=550, top=150, scrollbars=no')">Click Here</a>
I have done something like this previously and it has worked.
•
•
•
•
Great idea. I tried that, and for some reason, it didn't work.
//this will set $value to the $_GET variable 'value' if it is there else set it to default of 'NOTHING POSTED'
$value = (isset($_GET[value])) ? $_GET[value] ? 'NOTHING POSTED'; //do something with $value
echo "Your age is ". $value; Last edited by peter_budo; Apr 5th, 2008 at 1:32 pm. Reason: Keep It Organized - please use [code] tags
•
•
•
•
How are you calling the variable in PHP on my_form.php?
//this will set $value to the $_GET variable 'value' if it is there else set it to default of 'NOTHING POSTED'
$value = (isset($_GET[value])) ? $_GET[value] ? 'NOTHING POSTED';
//do something with $value
echo "Your age is ". $value;
•
•
•
•
Well, in the past, I haven't had to call it other than it's already set in a variable. Usually, when I create a link like "my_link.php?value=3", then in the page, my_link.php, I can simply echo $value, and it would echo "3". But I'll try what you've put.
$value = (isset($_GET[value])) ? $_GET[value] : 'NOTHING POSTED'; Last edited by peter_budo; Apr 5th, 2008 at 1:32 pm. Reason: Keep It Organized - please use [code] tags
![]() |
Similar Threads
- Passing data from forms from one page to another (JavaScript / DHTML / AJAX)
- Need to Pass Variables from form to form (JavaScript / DHTML / AJAX)
- Ajax javascript test if image file exists (JavaScript / DHTML / AJAX)
- Move Javascript Variable to PHP (JavaScript / DHTML / AJAX)
- get html element value using php (PHP)
- Who can help me get this scripts???? (PHP)
- AJAX : Am i right with the concept? (JavaScript / DHTML / AJAX)
- Form not sending email (PHP)
Other Threads in the PHP Forum
- Previous Thread: Displaying PHP result within HTML?
- Next Thread: errors and errors
Views: 5894 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail memmory menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select send server sessions sms soap source space speed sql static structure syntax system table tutorial up-to-date update updates upload url validation validator variable video web wordpress xml youtube





