CodeIgniter Forums
ajax wih CodeIgniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: ajax wih CodeIgniter (/showthread.php?tid=23287)



ajax wih CodeIgniter - El Forum - 10-06-2009

[eluser]handoyo[/eluser]
Hi all,i'm trying to create 3 textfield with CI by using form_input. One is for enter price,one is for enter the desire discount value,the last one is for the discounted price which is calculated from price and discount value..How do i achieve it with CI?Thanks a lot..


ajax wih CodeIgniter - El Forum - 10-06-2009

[eluser]davidbehler[/eluser]
No need for ajax or special CI feature, just use simple [removed])

I have the impression, that people tend to forget about old school coding whenever they hear "...framework..." ^^


ajax wih CodeIgniter - El Forum - 10-06-2009

[eluser]handoyo[/eluser]
What should i do then?Thanks...


ajax wih CodeIgniter - El Forum - 10-06-2009

[eluser]davidbehler[/eluser]
Try something along this lines:
Code:
<5cr1pt >
function update_disc_price()
{
  var new_value = $('price').getValue() - $('discount').getValue();
  $('disc_price').setValue(new_value);
}
</5cr1pt >
&lt;input name="price" id="price" value=""&gt;
&lt;input name="discount" id="discount" value=""&gt;
&lt;input name="disc_price" id="price" value="" /&gt;
Be aware, that this example uses the prototype framework and this can be done with "normal" js aswell, but I'm just to lazy to look the functions Wink

My example propably won't work, but you should be able to work with this...I guess.


ajax wih CodeIgniter - El Forum - 10-06-2009

[eluser]handoyo[/eluser]
How about using form_input?Is it possible to do it too?Thanks waldmeister..


ajax wih CodeIgniter - El Forum - 10-06-2009

[eluser]umefarooq[/eluser]
yes you can do with form_input here is example

Code:
form_input(array('name'=>'price','id'=>'price','value'=>''));



ajax wih CodeIgniter - El Forum - 10-06-2009

[eluser]handoyo[/eluser]
Where should i put the function?Is it on the view?Thanks..


ajax wih CodeIgniter - El Forum - 10-06-2009

[eluser]Zack Kitzmiller[/eluser]
You're _really_ over-complicating this. Just use a little bit of old-fashioned j@vascr1pt.


ajax wih CodeIgniter - El Forum - 10-07-2009

[eluser]handoyo[/eluser]
How to do it with old fashioned javascript?Thanks..