0

i have input type and button, i need when insert into

<input type="text" name="bills_ID" id="bills_ID" value="2">

i will get id for this item and put it into here

BillsPrint.php?bills_ID=id

this is full code

<form id="wrapper">
    <input type="text" name="bills_ID" id="bills_ID" value="2">
    <input name="print" type="submit" id="print" value="print" class="css3buttonblue"  onclick="window.open('BillsPrint.php?bills_ID='this.id, '_blank')" />
</form>
​

how can i put the id on this link BillsPrint.php?bills_ID=2 without refresh page

5 Answers5

0
<form id="wrapper">
    <input type="text" name="bills_ID" id="bills_ID" value="2">
    <input name="print" type="submit" id="print" value="print" class="css3buttonblue"  
onclick="window.open('BillsPrint.php?bills_ID=' + $("#bills_ID").val(), '_blank')" /> 
</form>

Matanya
  • 6,233
  • 9
  • 47
  • 80
0

Remove the onclick etc. And use get method. Use this simple code and the variables will come in URL as query string.

<form action="BillsPrint.php" method="get" id="wrapper">
<input type="text" name="bills_ID" id="bills_ID" value="2">
<input name="print" type="submit" id="print" value="print" class="css3buttonblue">
</form>

You forget to specify action of form. Use this code it will work. :) Hope it will help.

0

Try this:

$(document).ready(function(){
   $('form').submit(function(){
      var id = $('input[name="bills_ID"]').val();
      window.open('BillsPrint.php?bills_ID='+id, '_blank');
      return false;
   });
});
greener
  • 4,989
  • 13
  • 52
  • 93
0

You could do this:

 <form id="wrapper">
            <input type="text" name="bills_ID" id="bills_ID" value="2">
            <input name="print" type="submit" id="print" value="print" class="css3buttonblue"   />
        </form>
    <script>
       $(function(){
           $('#print').click(function(){
              window.open('BillsPrint.php?bills_ID='+$('#bills_ID').val(), '_blank')  
           }); 
       });
    </script>
A. Wolff
  • 74,033
  • 9
  • 94
  • 155
0
$("#print").click(function(){

   var id = $("#bills_ID").val();

    $.ajax({
      url: 'BillsPrint.php?bills_ID=' + id,
      success: function(data) {
        $('.result').html(data);
           alert(data); //alerts output from the BillsPrint.php page
      }
    });
});
Slavenko Miljic
  • 3,836
  • 2
  • 23
  • 36