JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old May 18th, 2004, 01:45 PM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
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

Reply With Quote
  #2  
Old May 18th, 2004, 08:41 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
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

Reply With Quote
  #3  
Old May 21st, 2004, 07:59 AM
pocketsized pocketsized is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Brunei
Posts: 26 pocketsized User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old May 22nd, 2004, 09:54 AM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
thanks. That helps

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > pasing variables from php to js


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway