last day (15 days later) » 

09:03
0
Q: Change chart data based on Ajax Selection Call

Mirza ChilmanI have a Chart with an select option for the Year, by the default the selection option will choose the newest Year, but the user can choose to see another data from another Year through this select option <script type="text/javascript"> $(document).ready(function() { $('table.highchart').highc...

can you show also your structure in html? specifically on where #tableChart is placed
@Riyenz ok hold on lemme update my question
@Riyenz u can check my question again, i have edited it
lets say the default is 2017 and you chose 2016. what will happen if you choose another value again like 2017 or 2015?
@Riyenz it will add another chart data in my view, like if i choose 2 year from select option then there will be 3 chart data 2017(default), 2016(1st selection), 2015(2nd selection)
Perhaps you have $chartData .= $theHTML on your controller? sorry but i dont see anything wrong on your javascript and html.
09:04
maybe we can discuss thi through chat?
is it possible that the error is in controller or my model?
yes
in your controller
since your creating a html on your controller right? then pass it to the ajax call. to create new html on the #tableChart.html()
public function list_data_project(){
$thn = $this->input->post('tahun');
$data['januari'] = $this->dashboard_m->get_kategori_totals('01',$thn)->num_rows();
$data['februari'] = $this->dashboard_m->get_kategori_totals('02',$thn)->num_rows();
$data['maret'] = $this->dashboard_m->get_kategori_totals('03',$thn)->num_rows()
//And the code above will be the same until december, the differences only in the parameter

$data['title']= 'Aplikasi Saranabudi';
$data['aktif'] = 'Jumlah Kategori Project';
$data['judul_hal']= 'Dashboard Kategori Project';
since im new in codeigniter so, im not sure what im doing actually
also with that
$data['januari'] = $this->dashboard_m->get_kategori_totals('01',$thn)->num_rows();
$data['februari'] = $this->dashboard_m->get_kategori_totals('02',$thn)->num_rows();
$data['maret'] = $this->dashboard_m->get_kategori_totals('03',$thn)->num_rows()
have you seen my response?
I have provided a shorter way so that you dont have to execute your query 12 times per year. only once
may i see your public function index()
i mean
public function list_data()
not public function list_data_project
yes i have seen ur answer but my focus is still to correcting this mistake first
ouw sorry i just realize i made an typo over there
it should be public function list_data_project()
not public function list_data()
is there any other way to send my selected year to my controller without using ajax?
now i see why
when you request the ajax
list_data is called
then
$this->load->view('dashboard/kategori_project/list_data',$data);
is being executed again
thats why your page appends
yes you can use form post
09:18
and then how to fix it?
ouw form post? ah then i need to change most of the code then
nope you dont need to change most
only the html
ouw really?
so what do u think is better
using ajax or just form?
Ill reply an answer :D
form :_
tell me if you encounter any problems
ok i will, let me try ur answer
where i do put that view? just copy paste it in my html? or do i need to use <?php ?> first?
oh my god, dumb question hahah, i know now
09:34
HAHAHA
THAT IS SWEET
it's work
and also that is a new way for me to use form
yeah its a good practice if ur using codeigniter
you can use ajax for confirmation if the data is inserted then load a view to redirect to the main page after success
thanks man, thanks again, its actually for my work and the deadline is 2 hours left from now, u just save me from being jobless haha
yeah bout that, bout ajax thing, it's overwhelming for me XD, like i said im still beginner
hahaha. Goodluck bro and have a nice day. just ask if you need help
thank you, and i WILL haha

last day (15 days later) »