|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
pasing variables from php to js
Hi. I need to pass a varaible from php to my js script. This is the case:
I have a admin site. And when the admin changes something in a users specs. He gets a js confirm(); but i need, that if this confirm is False, that js sets a variable ei. $Confirm = false; ore if the confirm(); is accepted, the $Confirm = true. - Pheifel |
|
#2
|
||||
|
||||
|
PHP can't read javascript variables.
However, why not just have the confirm() method only submit the form when the comfirm variable is True. If this doesn't answer your question, perhaps pasting some code would help us understand a little better |
|
#3
|
|||
|
|||
|
I'm a bit confused. Your thread title says you want to pass a variable from PHP to JS but your example (if I understand it correctly) appears to be trying to pass a variable from JS to PHP. For the former (PHP to JS), just have PHP print the appropriate command in the JS code:
<script> var confirmJS = <?php echo ($confirmPHP); ?>; </script> For the latter (JS to PHP) it is possible but it means either reloading the page or loading another PHP page. What I normally do is use Javascript to redirect the browser to another page but add the variable to be passed in the link. The code would look something like this: <script> var action = confirm ("...."); window.location = "doit.php?action=" + action; </script> In doit.php, the code would look something like this: <?php if (action) { /* Do something */ } else { /* Do something else */ } ?> Hope this helps. |
|
#4
|
|||
|
|||
|
thanks. That helps
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > pasing variables from php to js |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|