Jump to content

Recommended Posts

hey guys i have this invoice script im doing for my friend and it works until i add the auto suggest function that includes the jquery.js

why is it that when i combine different java scripts it cancel's out another?should i separate all my scripts in different pages and include them??

 

so basic

<html debug="true">
<head>
    <title></title>
    <script type="text/javascript" src="jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="jquery-calx-1.1.4.min.js"></script>
    
    
        <script type="text/javascript">
$(document).ready(function(){
   $('#calx').calx({
autocalculate: false
   });
   
   $('#calculate').click(function(){
$('#calx').calx('update');
   });
});
    </script>
    
    
    
    
    <style>
input[type="text"]{
   width:100%;
}
td{
   padding:5px 10px;
}
    </style>
</head>
<body>
    <form id="calx">
<table>
   <thead>
<tr>
   <td width="268" style="width:250px">Item Name</td>
   <td width="162" style="width:80px">Price</td>
   <td width="162" style="width:30px">Qty</td>
   
   <td width="168" style="width:150px">Sub Total</td>
</tr>
   </thead>
   <tbody>
<tr>
   <td><input id="item1" type="text" name="item[]" value=""/></td>
   <td><input id="price1" type="text" name="price[]" value="" data-format="$ 0,0[.]00" /></td>
   <td><input id="qty1" type="text" name="qty[]" value="" data-format="0" /></td>
  
   <td><input id="subtotal1" type="text" name="subtotal[]" value="" data-format="$ 0,0[.]00" data-formula="($price1*$qty1)" /></td>
</tr>
<tr>
   <td><input id="item2" type="text" name="item[]" value="" /></td>
   <td><input id="price2" type="text" name="price[]" value="" data-format="$ 0,0[.]00" /></td>
   <td><input id="qty2" type="text" name="qty[]" value="" data-format="0" /></td>
  
   <td><input id="subtotal2" type="text" name="subtotal[]" value="" data-format="$ 0,0[.]00" data-formula="($price2*$qty2)" /></td>
</tr>
<tr>
   <td><input id="item3" type="text" name="item[]" value="" /></td>
   <td><input id="price3" type="text" name="price[]" value="" data-format="$ 0,0[.]00" /></td>
   <td><input id="qty3" type="text" name="qty[]" value="" data-format="0" /></td>
   
   <td><input id="subtotal3" type="text" name="subtotal[]" value="" data-format="$ 0,0[.]00" data-formula="($price3*$qty3)" /></td>
</tr>
<tr>
   <td><input id="item4" type="text" name="item[]" value="" /></td>
   <td><input id="price4" type="text" name="price[]" value="" data-format="$ 0,0[.]00" /></td>
   <td><input id="qty4" type="text" name="qty[]" value="" data-format="0" /></td>
   
   <td><input id="subtotal4" type="text" name="subtotal[]" value="" data-format="$ 0,0[.]00" data-formula="($price4*$qty4)" /></td>
</tr>
<tr>
   <td><input id="item5" type="text" name="item[]" value="" /></td>
   <td><input id="price5" type="text" name="price[]" value="" data-format="$ 0,0[.]00" /></td>
   <td><input id="qty5" type="text" name="qty[]" value="" data-format="0" /></td>
   
   <td><input id="subtotal5" type="text" name="subtotal[]" value="" data-format="$ 0,0[.]00" data-formula="($price5*$qty5)" /></td>
</tr>
 
<tr>
   <td height="39"> </td>
   <td>Total Price : </td>
   <td colspan="2"><input id="total" type="text" name="total" value="" data-format="$ 0,0[.]00" data-formula="($subtotal1+$subtotal2+$subtotal3+$subtotal4+$subtotal5)" /></td>
   
</tr>
<tr>
 <td height="29"> </td>
 <td>Tax1:</td>
 <td colspan="2"><input id="totaltax1" type="text" name="totaltax" value="" data-format="$ 0,0[.]00" data-formula="($total+($total*5.00/100))" /></td>
 
 </tr>
<tr>
 <td height="29"> </td>
 <td>Tax2:</td>
 <td colspan="2"><input id="totaltax2" type="text" name="totaltax" value="" data-format="$ 0,0[.]00" data-formula="($total+($total*9.975/100))" /></td>
 
 </tr>
<tr>
 <td height="42"><input id="calculate" type="button" value="calculate" /></td>
 <td>Tax in :</td>
 <td colspan="2"><input id="totaltax" type="text" name="totaltax" value="" data-format="$ 0,0[.]00" data-formula="($total+($total*5.00/100+$total*9.975/100))" /></td>
 
 </tr>
   </tbody>
</table>
    </form>
    
</body>
</html>
Edited by techker
Link to comment
https://forums.phpfreaks.com/topic/290405-java-question/
Share on other sites

You called it "Java" in the thread title, but this is javascript. Java is an entirely different language.

 

As far as your question, your code seems to be fine.

1) you load main jq library

2) you load the calx library (is this a jquery library?)

3) you have custom code that sets up the calx library

 

Can you define "cancels each other out"?? What is happening exactly?

Link to comment
https://forums.phpfreaks.com/topic/290405-java-question/#findComment-1487713
Share on other sites

thx for the reply.sorry about the nob error..

 

when i add this to the page it works but the previous code does not?

 

 

<script>
$(document).ready(function(){
$('#calx').calx({
autocalculate: false
});
 
$('#calculate').click(function(){
$('#calx').calx('update');
});
 
  $("#P1").autocomplete("autocomplete.php", {
selectFirst: true
});
$("#P2").autocomplete("autocomplete.php", {
selectFirst: true
});
$("#P3").autocomplete("autocomplete.php", {
selectFirst: true
});
$("#P4").autocomplete("autocomplete.php", {
selectFirst: true
});
$("#P5").autocomplete("autocomplete.php", {
selectFirst: true
});
$("#P6").autocomplete("autocomplete.php", {
selectFirst: true
});
$("#P7").autocomplete("autocomplete.php", {
selectFirst: true
});
});
</script>
Link to comment
https://forums.phpfreaks.com/topic/290405-java-question/#findComment-1487841
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.