doctorbill
asked on
php java dropdowns
The following script changes the value of one drop box according to the value of another one
This is working finr on my php page
I need the following:
The variable #status needs to be defined from a php variable "statuscompleted[<?php echo $row_orders['ID']; ?>]"
The variable #currentstatus needs to be defined from a php variable "build[<?php echo $row_orders['ID']; ?>]"
<script src="jquery/jquery-1.8.3.m in.js">
</script>
<script type="text/JavaScript">
jQuery(document).ready(fun ction($) {
$("#status").change(functi on(){
if($("#status").val()=="Co mpleted"){
$("#currentstatus").val("C ompleted") ;
}
});
});
</script>
What I need to know is how to define the php variables so the javascript can use them
This is working finr on my php page
I need the following:
The variable #status needs to be defined from a php variable "statuscompleted[<?php echo $row_orders['ID']; ?>]"
The variable #currentstatus needs to be defined from a php variable "build[<?php echo $row_orders['ID']; ?>]"
<script src="jquery/jquery-1.8.3.m
</script>
<script type="text/JavaScript">
jQuery(document).ready(fun
$("#status").change(functi
if($("#status").val()=="Co
$("#currentstatus").val("C
}
});
});
</script>
What I need to know is how to define the php variables so the javascript can use them
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ray:
How do I do this please - in my code
'So all you need to do is place the PHP echo statements into the string variable that contains the JavaScript.'
How do I do this please - in my code
'So all you need to do is place the PHP echo statements into the string variable that contains the JavaScript.'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ray - how do I then check what is being passed to the browser from your script above
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nothing comes through - would it be in the head or body section
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can you tell me how to specify where the echo $jss; is sent so I can see the value of it
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
http://localhost/comwebsites/1callorders/site/orders_find_visit_print_custom_status_noforms_nocosts_idfilter2.php?p=1&ID[64]&ID[63]&ID[62]&ID[61]& ID[69]&pld te=97&sour cedte=Augu st%2031,%2 02012%209: 16am#ancho r5
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just noticed something:
The "$jss = <<<EOD" appears to be unrecognised by the page and the whole script is printed on the page
I have only noticed it because the background was black before and it did not show up
The "$jss = <<<EOD" appears to be unrecognised by the page and the whole script is printed on the page
I have only noticed it because the background was black before and it did not show up
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am just using this in the head section of my page (i already have a reference to the jquery file):
-------------------------- -------
<head>
......
$jss = <<<EOD
<script type="text/JavaScript">
jQuery(document).ready(fun ction($) {
$("#status").change(functi on(){
if($("#status").val()=="$r ow_orders- >ID"){
$("#currentstatus").val("$ row_orders ->ID");
}
});
});
</script>
EOD;
// WRITE THE JAVASCRIPT TO THE BROWSER
echo $jss;
</head>
--------------------------
<head>
......
$jss = <<<EOD
<script type="text/JavaScript">
jQuery(document).ready(fun
$("#status").change(functi
if($("#status").val()=="$r
$("#currentstatus").val("$
}
});
});
</script>
EOD;
// WRITE THE JAVASCRIPT TO THE BROWSER
echo $jss;
</head>
ASKER
ooops - looks like I forgot php tags
where exactly should they be on the script above ? - should this be in the section above the <head> tag, between php tags?
where exactly should they be on the script above ? - should this be in the section above the <head> tag, between php tags?
ASKER
This is the script as it is now in my page:
I still do not see anything being returned
Sorry but I can't put this on a public server yet - no access to it
<?php
/**
* RUN THE QUERY AND ACQUIRE THE ROW FROM THE RESULTS SET
* USE OBJECT-ORIENTED NOTATION TO RECOVER THE ROW (EASIER PUNCTUATION)
*/
// USE HEREDOC NOTATION TO CREATE THE JAVASCRIPT STRING
$jss = <<<EOD
<script type="text/JavaScript">
jQuery(document).ready(fun ction($) {
$("#status").change(functi on(){
if($("#status").val()=="$r ow_orders- >ID"){
$("#currentstatus").val("$ row_orders ->ID");
}
});
});
</script>
EOD;
// WRITE THE JAVASCRIPT TO THE BROWSER
echo $jss;
?>
I still do not see anything being returned
Sorry but I can't put this on a public server yet - no access to it
<?php
/**
* RUN THE QUERY AND ACQUIRE THE ROW FROM THE RESULTS SET
* USE OBJECT-ORIENTED NOTATION TO RECOVER THE ROW (EASIER PUNCTUATION)
*/
// USE HEREDOC NOTATION TO CREATE THE JAVASCRIPT STRING
$jss = <<<EOD
<script type="text/JavaScript">
jQuery(document).ready(fun
$("#status").change(functi
if($("#status").val()=="$r
$("#currentstatus").val("$
}
});
});
</script>
EOD;
// WRITE THE JAVASCRIPT TO THE BROWSER
echo $jss;
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
ASKER
This is the problem
the elements are :
id = "statuscompleted[<?php echo $row_orders['ID']; ?>]"
id ="build[<?php echo $row_orders['ID']; ?>]"
How exactly do I get these into the jQuery - cpuld you please show in the posted script please?