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
 
Unread Codewalkers Forums Sponsor:
  #1  
Old January 6th, 2003, 05: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, 02:05 PM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,331 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: 26229 Folding Title: Starter FolderFolding Points: 26229 Folding Title: Starter Folder
Time spent in forums: 6 Days 15 h 33 m 41 sec
Reputation Power: 5
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, 06: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, 06:54 PM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,331 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: 26229 Folding Title: Starter FolderFolding Points: 26229 Folding Title: Starter Folder
Time spent in forums: 6 Days 15 h 33 m 41 sec
Reputation Power: 5
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, 11: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: 25
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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek