0

This calls and changes the values

 <select  width="100" name="produto" id="produto-list" class="produtoInputBox"   onChange="getapolice(this.value);" <?php echo $permissao; ?> >

i have this function

function getapolice(val1,val2) {
  $.ajax({
  type: "POST",
  url: "caixa/inc/get_apolice.php?id='<?=$_GET['id']?>'",
  data:'com_id='+val1+'&produtname_id='+val2,
    success: function(data){
     $("#apolice-list").html(data);
    }
  });
}

Whit this i get com_id = "i get value" and produtname_id = undefined but if i change this line on the script

 data:'produtname_id='+val1+'&com_id='+val2,

I get produtname_id = "i get value" and com_id = undefined

Thanks for the help

5
  • your val2 is undefined check that if it has values Commented May 23, 2016 at 11:10
  • Show the code that calls the function. Also, no need to try and build the data string manually, just use an object and jquery will format it correctly: data:{com_id: val1, produtname_id:val2}, Commented May 23, 2016 at 11:11
  • You haven't passed 2nd argument in function. Commented May 23, 2016 at 11:17
  • Write getapolice(this.value,2) and you will get val2=2 Commented May 23, 2016 at 11:20
  • i don't want a fixed value thanks Commented May 23, 2016 at 13:02

1 Answer 1

1

change this

   <select  width="100" name="produto" id="produto-list" class="produtoInputBox"   onChange="getapolice(this.value);" <?php echo $permissao; ?> >

to

 <select  width="100" name="produto" id="produto-list" class="produtoInputBox"   onChange="getapolice(this.value, '2nd value');" <?php echo $permissao; ?>> //missed your val2
Sign up to request clarification or add additional context in comments.

2 Comments

<?php echo $permissao; ?> that is only to allow or disabel the drop down box
getapolice function has val1 and val2. val1 = this.value. val2 = ?

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.