JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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 March 22nd, 2002, 04:44 AM
rehab rehab is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 3 rehab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
javascript into php

<script>

c=document.forms[0].category.options[document.forms[0].category.selectedIndex].text
<?php
$x=c;
?>

</script>

but the php doesn't understand this c variable

Reply With Quote
  #2  
Old March 22nd, 2002, 05:31 AM
Taddis Taddis is offline
newbie
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Location: Stockholm
Posts: 8 Taddis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 36 m 38 sec
Reputation Power: 0
Send a message via ICQ to Taddis
Im no javascript kiddie.. infact I hate it ;o)

But anyways.. you will not be able to access javascript variables in a php script in the same page.
You have to have this in mind:
javascript is a "clientside" scripting language
php is a "serverside" scripting language

To get the vars from the javascript you will atleast have to make a page refresh or a post of some kind.

cheers

Reply With Quote
  #3  
Old March 22nd, 2002, 05:40 AM
mitchell mitchell is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Bournemouth, England
Posts: 28 mitchell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 23 sec
Reputation Power: 0
Send a message via ICQ to mitchell Send a message via MSN to mitchell
Unhappy javascript and php

Hiya Rehab

no javascript and php are not very good mates and you sometimes have to find a way round things.

Any how, what exactly are you trying to do? Is the option selected for the user before the page is sent to the browser? If not you can't do anything on the same page with php after its been sent. All the php has finished running BEFORE its sent to the browser so u can't have an onSelect do stuff in php thang.

If your php code is on the next page after posting just use the name of the form object as the variable and there's your value.

If the problem is that you're losing multiple selections on post try this
function reportMultiple()
{/*Deals with multiple size selections - creates a ; seperated list*/
var full_size_list = "";
var the_select = document.form1.item_size2;
for (counter=0; counter<the_select.options.length; counter++)
{
if (the_select.options[counter].selected == true)
{
full_size_list += the_select.options[counter].value + ";";
}
}
document.form1.full_size_list.value = full_size_list;
event.returnValue=true;
}

<form name="form1" onSubmit="reportMultiple();" method="post" action="editingItem.php" enctype="multipart/form-data">

and on the 2nd page this

$size_list = explode(';',$full_size_list);

If I've not helped give me a bit more detail of exactly what your trying to achieve

Mitchell

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > javascript into php


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 2 hosted by Hostway
Stay green...Green IT