can any one help to me to get variable from jquery and use in php

76

Solution:

I understand the question and the answer is going to be complex. First you need to add onChange event to your ProducerType selectbox. Add this at the end of your html:

<script>
$(document).ready(function(){
   // attach event on change
   $('#ProducerType').on('change',function(){
      // call script on server to check if isset() and receive values for Role
      $.get("checkproducer.php?ProducerType="+$('#ProducerType').val(),function(result){
               // here the script on server returned data already
               // update Role selectbox with new values
               $('#Role').html(result)
           })
   })
})
</script>

Make sure you have jquery.js loaded as usual.

You will need to create a PHP script on server which handles the check and returns new data for your select input. Like this (save as "checkproducer.php"):

<?php
    if ($_GET['ProducerType']=="Principal")
       echo "<option value=1>Principal1</option>"
           ."<option value=2>Principal2</option>";
    if ($_GET['ProducerType']=="Producer")
       echo "<option value=1>Producer1</option>".
           ."<option value=2>Producer2</option>";
    if ($_GET['ProducerType']=="SoleProprietor")
       echo "<option value=1>SoleProprietor1</option>"
           ."<option value=2>SoleProprietor2</option>";

    // etc
?>

People are also looking for solutions to the problem: PHP MySQL if row exists not doing anything

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.