> -----Original Message-----
> From: Nicole Lallande [mailto:[EMAIL PROTECTED]]
> Sent: 10 March 2001 00:12
> To: [EMAIL PROTECTED]
> Subject: printing data using javascript with php
> 
> 
> 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):

if you want this to happen in the browser you have to have all the info sent
with the page. I would do this with invisible DIV's which you can make
visible or invisible in Javascript. I usually do something like
obj.style.display = "" to show and obj.style.display = "none" to hide.

if you want to get from the database every time you have to resubmit, which
is slower and looks crap.

> 
> //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>"; }

if you want $dsc to be available to the javascript you have to send it with
the html, either as a hidden field or in the query string. In this case what
you may be wanting to do is send the contects of $dsc in which case replace
document.write(dsc) with document.write('" . $dsc . "')") or however you
like to do this sort of concatenation.

> 
> 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
> [EMAIL PROTECTED]
> 760.753.6766
> ########################
> 

it's hard to tell precisely what you want to do form your snippets, but I
hope I've been of some help.

        Tim Ward
        Senior Systems Engineer

Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to