Welcome Guest, Not a member yet? Register   Sign In
I need some help with Jquery Ajax with CI
#1

[eluser]Unknown[/eluser]
Alright So I'm creating this application to measure volume of merchandise that fit into all the different size freighters.

This is my first attempt at making a web application with codeigniter and for the most part has been a smooth process. I hit a little bump with jquery where i need the user to type an amount of product he wants in an order. But since the company works mostly with master cartons (meaning if we want 30 of productA and productA MC is 15 then we want to submit 2 boxes are needed).

I tried to solve this little form with Jquery/Ajax and codeigniter.

I need to enter the amount of products on the left field and show how many boxes that is on the right field with ajax. If the number inst an integer( or whole number) then show an error.

my view
Code:
<?php if(isset($records)) : foreach($records as $row) :
echo "<tr>";
echo "<td>".$row->upc."</td>";
  echo "<td>".$row->desc."</td>";
   echo "<td>".$row->model."</td>";
    echo "<td>".$row->product_MC."</td>";
    echo "<td>";
      $data = array(
              'name'        => "perProd",
              'id'          => "perProd",
              'size'        => '5'
            );

    echo form_input($data);
    $hidden = array('productID' => $row->id, 'orderID' => $id);
      echo form_open("start/addProduct/$id", '', $hidden);
    echo "</td>";
    echo "<td>";
    
    $data = array(
              'name'        => "amount",
              'id'          => "amount",
              'size'        => '5'
            );
    echo form_input($data);
    echo "</td>";
    echo "<td>";
  echo form_submit('submit', 'Add to Order');
echo form_close();    
echo "</td>";
echo "</tr>";
endforeach;
else : ?&gt;    
    <br/><br/><tr>No records were returned.</tr> <br/>
    &lt;?php endif; ?&gt;

this is the controller for the ajax call so far just to return the value back to the other field.
Code:
function perProduct(){
    $amount = $this->uri->segment(3);
    $success = true;
    //if the validation was a success
    if ((IS_AJAX && $success) || (!IS_AJAX && $success)) { echo $amount; }else{echo "error";}

    }

This is the jquery I'm working with right now.

Code:
$(document).ready(function() {
    $('#perProd').blur(function() {
        $.ajax({
            url: '../perProduct/' + $(this).val(),
            type: 'post',
            success: function(result) {
                $('#amount').val(result);
            }
        });
    });
});

Im a fairly new developer so I apologize if this seems like a simple problem :/


Messages In This Thread
I need some help with Jquery Ajax with CI - by El Forum - 04-13-2010, 03:34 PM
I need some help with Jquery Ajax with CI - by El Forum - 04-13-2010, 03:38 PM
I need some help with Jquery Ajax with CI - by El Forum - 04-13-2010, 03:44 PM
I need some help with Jquery Ajax with CI - by El Forum - 04-13-2010, 06:51 PM
I need some help with Jquery Ajax with CI - by El Forum - 04-13-2010, 07:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB