printing data using javascript with php
| From: | Nicole Lallande | Date: | Sat, 10 Mar 2001 00:11:47 +0000 |
| Subject: | printing data using javascript with php | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-43246@lists.php.net to get a copy of this message | ||
Dear Gurus:
I am trying to use javascript with my php code to output data onChange.
I have read the archives and know that because javascript is client side
and php is server side I cannot interact natively on the page except to
pass the variables through an http request. Here is what I have done
based on what I have read in the archives etc.:
<script language="javascript">
<!--
function setboo() {
var boo = <?php echo $boo ?>;
var dsc = <?php echo $dsc ?>;
var sz = <?php echo $sz ?>;
var prc = <?php echo $prc ?>;
document.forms[0].boo.value+=1;}
-->
</script>
$boo is set to 0 within the php code and I am setting it to one with the
javascript because I thought I could then use an if statement:
//here is where boo gets set to one
echo "<td width=\"100\" align=\"left\"><select
name=\"catalog_id\"
onChange=\"setboo()\">";
this is the html code for the document.forms <input type="hidden"
name="boo" value="1">
so what is supposed to happen here is the user selects a product by its
id number and presto - the rest of the information will be written to
the fields along side (I wish):
//here is the if statement
if ($boo == '1') {
echo "<td width=\"350\" align=\"left\"><input
type=\"text\"
name=\"description\" onChange=\"javascript:
document.write(dsc)\"></td>"; }
where $dsc is set equal to an array element read in from a database in
the php code. Now I KNOW I have got things MAJORLY confused here - but
the more I read the more wrapped up I seem to get so if there a way to
pull this off and someone knows - I would appreciate your help
Thanks,
Nicole
--
########################
Nicole Lallande
nicole@nmlconsulting.com
760.753.6766
########################