Web Analytics Made Easy -
StatCounter Javascript change - CodingForum

Announcement

Collapse
No announcement yet.

Javascript change

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript change

    I didnt code this javascript and i am having a hard time figuring out how to change this code for a field not to be editable and be static but still take the id field and do the calculation

    you can view the site at as a demo at Demo


    I want the Price field to be static right now its editble the code involved is using PHP Mysql and Javascript

    I know i need to change the function but i dont know where, can anyone help me out here?

    thanks

    Code:
    <SCRIPT>
    function calc_subtotal(param)
    {
    
    var total=$("#price"+param).attr('value')*$("#quantity"+param).attr('value');
    $("#total"+param).text(total.toFixed(2)+'');
    update_grandtotal();
    }
    
    function update_grandtotal()
    {
    var total=0;
    var arr=$("div[@id^='total']");
    
    for (var i=0;i<arr.length;++i)
    total+=parseFloat(arr[i].textContent);
    
    $("#grandtotal").text(total.toFixed(2)+'');
    
    }
    
    function savedata()
    {
    
    	var arr=$("input[@id^='id']");
    
    	for (var i=0;i<arr.length;++i)
    	{
    	var param=arr[i].value;
    	var id=parseInt(param);
       var price = parseFloat($("#price"+param).attr('value'));
       var quantity = parseInt($("#quantity"+param).attr('value'));
       var total = parseFloat($("#total"+param).text());
    
    	$.post("save.php", { id: id, quantity: quantity, price: price, total: total } );
    	}
    
    }
    
    
    setTimeout("update_grandtotal();", 500);
    
    
    
    </SCRIPT>

  • #2
    Why not just give the price fields a disabled attribute? It will make them non-editable and the calculations will still work. See how here:

    http://www.w3schools.com/tags/att_input_disabled.asp
    The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

    How to ask smart questions?

    Comment


    • #3
      You are awesome thanks for the help.

      Comment

      Working...
      X