|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > javascript into php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|