-2

I would take the value of the combobox by using getelementbyID to PHP variable, And The Code Like This

<select name="PROPINSI" onchange="document.getElementById('KOTAA').value = this.value" >
    <option value="a">a</option>
    <option value="b">b</option>            
 </select>

<select name="KOTA" id="KOTAA">
     <?php
         $propinsi = ; //in this variable, I want take this value

         $sqll="SELECT kota FROM master_propinsi WHERE propinsi = '$propinsi'";
                   $hasill= mysql_query($sqll);


                    while($dataa = mysql_fetch_array($hasill))
                    {            
                      echo "<option value='$dataa[kota]'>$dataa[kota]</option>";             
                    }

    ?>
 </select> 

Can SomeOne Help Me?

I really appreciate your answer Thanks

How to get value From Combo Box with ID="KOTAA" to variable $propinsi

2 Answers 2

2

You cannot pass variable values from the current page javascript to the current page PHP code... PHP code runs at the server side and it doesn't know anything about what is going on on the client side.

You need to pass variables to PHP code from html-form using another mechanism, such as submitting form on GET or POST methods.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for answer, I have try the submit, like onChange="this.form.submit()" and in $propinsi = $_GET[PROPINSI], but it not work.., anyhting Wrong with my code?
Is it inside the form tag?
yes, <select name="PROPINSI" onchange="this.form.submit()"> inside Select tag
It Resolve, with this.form.submit, the problem is $_GET, my Form method is $_POST. Thanks
0

You can't put javascript code in PHP. Although, there is an alternative: Ajax

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.