Welcome Guest, Not a member yet? Register   Sign In
Submit form using AJAX
#11

[eluser]GrootBaas[/eluser]
Can I pass parameters to my controller in my form submit statement

Code:
document.update_logs().submit();

update_logs - My function in the controller that will build my new form.
#12

[eluser]Randy Casburn[/eluser]
Right. Load up hidden form fields with your JS data. It's that simple.

You have two options:

1) submit the form normally
- if you use this method, you'll need to build hidden form fields with your JS variables so they get submitted with your form

2) send the data via JSON in an AJAX request
- if you do this, in order to "build your page", you'll need to replace the content of the portions of the page with a reply to your AJAX request. ie. Replace <div id="foo">blah</div> with the AJAX response <div id="bar">trah</div>

Randy
#13

[eluser]GrootBaas[/eluser]
[quote author="Randy Casburn" date="1224665040"]Right. Load up hidden form fields with your JS data. It's that simple.

You have two options:

1) submit the form normally
- if you use this method, you'll need to build hidden form fields with your JS variables so they get submitted with your form

2) send the data via JSON in an AJAX request
- if you do this, in order to "build your page", you'll need to replace the content of the portions of the page with a reply to your AJAX request. ie. Replace <div id="foo">blah</div> with the AJAX response <div id="bar">trah</div>

Randy[/quote]

Randy, I wish I can buy you a beer for your effort.

Definitely option 1....

How would I build hidden form fields in JS?
#14

[eluser]Randy Casburn[/eluser]
I wouldn't...I would build them in PHP and only populate late the value='' part with a simple JS substitution.

So your PHP script would send out a fully populated form with a bunch of hidden fields and all your JS would have to do is substitute the values when the onSubmit() event fires off.

Make sense?

Randy
#15

[eluser]GrootBaas[/eluser]
[quote author="Randy Casburn" date="1224666361"]I wouldn't...I would build them in PHP and only populate late the value='' part with a simple JS substitution.

So your PHP script would send out a fully populated form with a bunch of hidden fields and all your JS would have to do is substitute the values when the onSubmit() event fires off.

Make sense?

Randy[/quote]

That makes a lot of sense ...

How would I substitute the value of the hidden form field with JavaScript
#16

[eluser]GrootBaas[/eluser]
Hey Randy,

I got my stuff to work!

Thanks mate!

I also understand the AJAX issue. Thanks again.
#17

[eluser]Randy Casburn[/eluser]
I'm holding you to that beer... :-)

Any time, glad I was around to help,

cu...Randy
#18

[eluser]Pramod[/eluser]
Hi,
I need Flexigrid with extra search parameter(search form outside the frame).
I have done for one case like this

Add search Criteria
Code:
$searchCriteria=array(
        'validity_dt_from' => $this->general_model->dateInSecond($_POST['validity_dt_from'],'dd/mm/yyyy'),
        'validity_dt_to' => $this->general_model->dateInSecond($_POST['validity_dt_to'],'dd/mm/yyyy'),
        'exp_dt_from' => $this->general_model->dateInSecond($_POST['exp_dt_from'],'dd/mm/yyyy'),
        'exp_dt_to' => $this->general_model->dateInSecond($_POST['exp_dt_to'],'dd/mm/yyyy'),
        'p_distributor' => $_POST['p_distributor'],
        'state' => $_POST['state'],
        'alis_name' => $_POST['alis_name'],
        'par_value_from' => $_POST['par_value_from'],
        'par_value_to' => $_POST['par_value_to']
        );

And pass to ajax file as

Code:
$grid_js = build_grid_js('flex1',site_url("Reports/mposAjax/getdataCTC"),$colModel,'REPORT_ID','asc',$gridParams,$buttons,$searchCriteria);

Then I modified in flexigrid.js in line ~585

Code:
if (p.page>p.pages) p.page = p.pages;
                var param = {page:p.newp, rp: p.rp, sortname: p.sortname, sortorder: p.sortorder, query: p.query, qtype: p.qtype,state:p.state,validityDateFrom:p.validity_dt_from,validityDateTo:p.validity_dt_to,expDateFrom:p.exp_dt_from,expDateTo:p.exp_dt_to,destri:p.p_distributor,aliasName:p.alis_name,parValueFrom:p.par_value_from,parValueTo:p.par_value_to};

I also changed sql for advance serach criteria.

But problem is it works for only one form.
If i want this for many form how Can i do it.

I have paging problem in Oracle since oracle doesnot support LIMIT.

Can any one can help me.
Thanks in advance
#19

[eluser]Randy Casburn[/eluser]
I'm not too familiar with the flex grid implementation, but it appears your sending your request to 'flex1'?

You may need to create two jquery grids on your page with different DOM ids. Then send your JSON requests to those individual grids by corresponding id.

Again, though, I'm not familiar at all with this flex grid.

Hope this is somewhat helpful though,

Randy
#20

[eluser]GrootBaas[/eluser]
Pramod,

I used this approach to change the data inside FlexiGrid based on a search criteria.

Code:
$("#log_cust_code").change(function()
{
  var cust_code = $("#log_cust_code").val();
  var fbt_year = $("#fbt_year").val();
  var dt = $("#log_cust_code").serializeArray();

  var pg = new Object;
  pg.name ='page';
  pg.value = 1;
  dt.push(pg);
                
  $("#flex1").flexOptions({params:[{name:'v_cust_code', value: cust_code},     {name:'v_fbt_year', value: fbt_year} ], newp: 1});
  
  $("#flex1").flexReload();
                
  $("#log_rego").val('');
                                  
  return true;
});


You can then pick the values up in your FlexiGrid library as follows ...

Code:
if ($this->post_info['swhere'] == TRUE && $this->CI->input->post('v_cust_code') == FALSE && $this->CI->input->post('v_fbt_year') == FALSE && $this->CI->input->post('v_rego') == FALSE)
        {
            log_message('debug', 'SEARCH = TRUE and CUST_CODE = FALSE and FBT = FALSE and REGO = FALSE');
            
            $return['main_query'] = str_replace('{ACC_CODE}', $pi_acc_code, $querys['main_query']);
            $return['count_query'] = str_replace('{ACC_CODE}', $pi_acc_code, $querys['count_query']);
            
            $return['main_query'] = str_replace('{FBT_YEAR}', $fbt_year, $return['main_query']);
            $return['count_query'] = str_replace('{FBT_YEAR}', $fbt_year, $return['count_query']);
            
            $return['main_query'] = str_replace('{REG_NO}', 'NULL', $return['main_query']);
            $return['count_query'] = str_replace('{REG_NO}', 'NULL', $return['count_query']);
            
            $return['main_query'] = str_replace('{SEARCH_STR}',($use_where == 1 ? ' WHERE UPPER(' : '').$this->post_info['swhere'],$return['main_query']).')';
            $return['count_query'] = str_replace('{SEARCH_STR}',($use_where == 1 ? ' WHERE UPPER(' : '').$this->post_info['swhere'],$return['count_query']).')';
            
            $return['main_query'] = str_replace('{ORDER_BY}', 'ORDER BY ea.account_name desc',$return['main_query']);
            $return['count_query'] = str_replace('{ORDER_BY}','ORDER BY ea.account_name desc',$return['count_query']);
            return $return;
        }

So if you want FlexiGrid on more than one page, just have another FlexiGrid library...




Theme © iAndrew 2016 - Forum software by © MyBB