Welcome Guest, Not a member yet? Register   Sign In
jquery and CI
#4

[eluser]Amitabh Roy[/eluser]
You are setting the values of counter and m. And you have defined them as javascript variables.

For a more convenient programming I think it would be a better option to define them as hidden fields

Code:
<input type='hidden' value='' id='m'>
<input type='hidden' value='2' id='counter'>

In this way you can access the m and counter values more efficiently

Code:
$(document).ready(function() {
      $("#addButton").click(function(){
        
       // counter++;  
        var tempCounter = $('#counter').val();
       $('#counter').val(tempCounter++);

          ....middle section of the code is bit unclear...........
        
        var tempM =$('#textbox' + tempCounter).val();
       $('#m').val(tempM);

});
});



Now you can access the hidden fields m and counter from anywhere in the view using jquery.

Code:
$('#counter').val();
$('#m').val();
And if you need to send m and counter to the server, call the $.ajax method of jquery and pass the values
of the hidden fields m and counter to the server as parameters in the ajax call.


Messages In This Thread
jquery and CI - by El Forum - 07-08-2011, 05:18 AM
jquery and CI - by El Forum - 07-08-2011, 07:24 AM
jquery and CI - by El Forum - 07-08-2011, 09:34 AM
jquery and CI - by El Forum - 07-08-2011, 10:37 AM
jquery and CI - by El Forum - 07-08-2011, 01:13 PM
jquery and CI - by El Forum - 07-08-2011, 01:16 PM
jquery and CI - by El Forum - 07-08-2011, 01:18 PM
jquery and CI - by El Forum - 07-08-2011, 01:54 PM
jquery and CI - by El Forum - 07-09-2011, 02:56 AM
jquery and CI - by El Forum - 07-10-2011, 06:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB