Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old January 6th, 2003, 04:32 PM
sparkrulez sparkrulez is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: london
Posts: 2 sparkrulez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to sparkrulez
php-javascript passing variables?!?!

I am developing a web application in php/javascript/dom... Recently I discovered the benefits of using dom with javascript... ie:being able to edit data without refreshing the browser, and seeing that my goal is to develop a fast application that works over an intranet it seemed that dom was the answer.

Now what I would like to do is start passing these javascript variables to php which is activated through javascript functions. Well my problem is basic, I have tried just about everything and I can’t seem to pass variables from javascript to php or from php to javascript?!?!?!

Also when I have php attached in javascript functions it seems to run once and only once.

Example:
<HTML>
<button onClick="php_script();">PHP_VAR_TEST</button>

<script>
var php_string =”0”;

function php_script()
{
php_string =”<?$string1=string1+1;echo string1;?>”;
alert(php_string);
}

</script>
</HTML>

Now, when I call the above script through a button command all I ever seem to get is the value 1. Every time I activate this command with the button. WHY? Which does the value of +1 only work once?

Can anyone out there explain what I am doing wrong and how I can make this possible?

Thanks in advance….

Chad

Reply With Quote
  #2  
Old January 7th, 2003, 01:05 PM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,310 tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 7832 Folding Title: Novice Folder
Time spent in forums: 6 Days 4 h 57 m 58 sec
Reputation Power: 4
RE: php-javascript passing variables?!?!

Sorry, but I don't seem to understand. You want to run php commands from JavaScript? I don't think that's possible because php commands are handled by the server and JavaScript commands are handled by the browser. So if you want to do php commands, the page must be refreshed.

And the little piece of code. Put it this way:
Code:
function php_script()
{
php_string =”<?$string1=$string1+1;echo string1;?>”;
alert(php_string);
} 


What's different? If you give command $string1=string1+1, the $string1 will get the value from the variable string1. I suppose it should get its value from variable $string1 (from itself), right?

Reply With Quote
  #3  
Old January 7th, 2003, 05:15 PM
sparkrulez sparkrulez is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: london
Posts: 2 sparkrulez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to sparkrulez
RE: php-javascript passing variables?!?!

Darn... that's not the answer I was hoping to receive. I can't refresh the entire page that will defeat my objective. My objective is to create a fast application that doesn't have to refresh.

I have discovered that DOM is very powerful and so far I am having great success. Uhmm there has got to be some way to accomplish what I want.

Perhaps, I can find someway to post my javascript variables to a hidden php frame…and then have that data sent back to the javascript. That way it wouldn’t have to refresh the whole page…it would just refresh content on the page that was invisible.

Either that…or I am going to have to learn to manipulate DOM through php… which will probably mean I would have to re-write my entire application… <evil grin>…

Does this make any sense? LMAO

You see the only real reason I need PHP is to call certain data from my mysql database and then update the database every time a customer finishes a transaction.

Oh…in case anyone is wondering I am developing a web based cash register terminal for one of my customers.

Reply With Quote
  #4  
Old January 7th, 2003, 05:54 PM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,310 tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 7832 Folding Title: Novice Folder
Time spent in forums: 6 Days 4 h 57 m 58 sec
Reputation Power: 4
RE: php-javascript passing variables?!?!

If it's only MySQL why you need php, why won't you code java applet instead of JavaScript? If I remember right it is possible to work with databases when using java applets. For more info on java applets and java, visit http://java.sun.com

Reply With Quote
  #5  
Old February 11th, 2003, 10:43 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: php-javascript passing variables?!?!

Just a thought...

1. Fiddle with data using Javascript.
2. Write resulting JavaScript variable to hidden field in a form.
3. Read hidden field with PHP.
4. Process final page with PHP refresh.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > php-javascript passing variables?!?!


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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