JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

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 Dev Shed Forums Sponsor:
  #1  
Old June 25th, 2001, 09:56 PM
yoshimitsu yoshimitsu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Adelaide
Posts: 72 yoshimitsu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
php and javascript

Hi,
I have a javascript function returning a value. I would like to know how I can use this value in my php code.

I am using a switch statement.

switch("") <--- i want to use that value from my javascript
function in here !
{
case 1: blah blah
}

How can I do this??

Thanks for any replies.......

yoshi

Reply With Quote
  #2  
Old June 26th, 2001, 04:40 PM
Theeggman Theeggman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 266 Theeggman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 33 sec
Reputation Power: 12
What I have done is use a form to set a hidden form element equal to a javascript value. Then I print out that form value in PHP.


To take a variable from PHP I use something like


document.value=<? print "$value"; ?>

Reply With Quote
  #3  
Old June 26th, 2001, 04:43 PM
yoshimitsu yoshimitsu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Adelaide
Posts: 72 yoshimitsu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Could you send me an example please. It's hard to understand without an example.

Appreciate the help.

Regards,
Yoshi

Reply With Quote
  #4  
Old June 26th, 2001, 05:13 PM
Theeggman Theeggman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 266 Theeggman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 33 sec
Reputation Power: 12
Here you go the first is the HTML file you need, then there is a very simple php file to post to. You must first click the 'click here' then click submit.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<META NAME="GENERATOR" CONTENT="MAX's HTML Beauty++ ME">
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
function test(apply) {
document.colorss.Form_Text_Decoration.value='test';
}
</SCRIPT>
</HEAD>

<BODY>


<a href="#" onclick="test();">Click Here</a>

<form method="post" name="colorss" action="css.php">
<input type="hidden" name="Form_Text_Decoration" size="10" maxlength="6">
<input type="submit" value="submit">
</form>

</BODY>
</HTML>

This is the PHP file.

<?
print "$Form_Text_Decoration";
?>

Reply With Quote
  #5  
Old June 26th, 2001, 05:16 PM
yoshimitsu yoshimitsu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Adelaide
Posts: 72 yoshimitsu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Theeggman thanks alot for your prompt reply.

later,

Yoshi

Reply With Quote
  #6  
Old June 26th, 2001, 10:27 PM
mbritton72 mbritton72 is offline
Shrill Digital God
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Raleigh, NC
Posts: 64 mbritton72 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m
Reputation Power: 12
Thanks for the cool demonstration.

Just fooling around, I used the onClick handler on the submit button:

<form method="post" name="colorss" action="test.php">
<input type="hidden" name="Form_Text_Decoration" size="10" maxlength="6">
<input type="submit" value="submit" onClick="test();">
</form>

Wonder if it works with Netscape...
__________________
I'm not impatient, I just have a low tolerance for boredom.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > php and javascript

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap