p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: PHP, Datenbank-Zugriff, JavaScript


Message #1 by "Hans Wolter" <hans.wolter@d...> on Fri, 25 Oct 2002 09:29:54
Dear community,

I have the following code within a php file:

<?php

...

            print $rs_FoHG->GetMenu($sel_FoHG_name, $defstr='',
                                    $blank1stItem=false, $multiple=false,
                                    $size=0,
                                    $selectAttr='onChange=show_sel_HG()',
                                    $compareFields0=true);

            echo "
                  <script language='JavaScript'>
                    Wert=document.forms[0].FoHG.selectedIndex;
                    Inhalt = document.forms[0].FoHG.options[Wert].text;
                  </script>
            ";

...

?>

With the GetMenu function I generate a selectionbox. When I choose a new 
entry within the selectionbox, I want to assign the value of the new 
choosen entry to a php variable. To get the choosen value of the 
selectionbox I use the above 4 JavaScript lines of code. Now I only need 
the syntax for assigning the content of the JavaScript variable "Inhalt" 
to a php variable.

Is there anybody out there with a good idea to solve this problem?

Thanks for your help!

Hans
Message #2 by "Nikolai Devereaux" <yomama@u...> on Fri, 25 Oct 2002 10:14:57 -0700
Since javascript happens on the client side, you'll need to submit the form
back to the server to have PHP aware of it.

The input name appears to be "FoHG", so depending on your form method, your
value will be in either $_POST['FoGH'] or $_GET['FoHG'].

Take care,

Nik


  Return to Index