Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
613 views
in Technique[技术] by (71.8m points)

PHP: Get the value from javascript using getElementbyId

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...