| | |
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
| Thread Tools | Search this Thread |
.htaccess apache api array autocomplete beginner binary body broken cakephp class cms code convert cron curl database dataentry date date/time display duplicates dynamic ebooks email emptydisplayvalue error execute explodefunction file firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include ip javasciptvalidation javascript joomla keywords limit link login mail matching mediawiki menu methods multiple mycodeisbad mysql network number object oop paypal pdf php phpincludeissue query random recursive redirect remote script search securephp server sessions shot source sp space speed sql subdomain subscription system table tag tutorial tutorials upload url validator variable vbulletin video web white youtube





