CodeIgniter Forums
how to return a value of one form to another form in the same view. - 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: how to return a value of one form to another form in the same view. (/showthread.php?tid=50702)



how to return a value of one form to another form in the same view. - El Forum - 04-05-2012

[eluser]noname525[/eluser]
vv


how to return a value of one form to another form in the same view. - El Forum - 04-05-2012

[eluser]boltsabre[/eluser]
Yeah, when your image upload form is submitted, just do your normal things, and assign your $data with your value and load the view you want to.

Code:
//your image form controller

   // you've done your validation, model stuff etc, now populate your $data
   $data['my_hidden_input_value'] = $image_filename;
   $this->load->view('my_upload_and_members_update_view', $data);

and in your view, just run a php isset() for your variable check in your hidden input
Code:
<input type="hidden" value="<?php if(isset($my_hidden_input_value)) echo $my_hidden_input_value; ?>" />



how to return a value of one form to another form in the same view. - El Forum - 04-05-2012

[eluser]LuckyFella73[/eluser]
When uploading a file via ajax you have a success function
that is fired when you get the expected return value.
You can return a json for example containing the filename
of the file you just uploaded. Take that one and push in
into the hidden input field. Jquery makes it pretty easy.


how to return a value of one form to another form in the same view. - El Forum - 04-06-2012

[eluser]boltsabre[/eluser]
Ah yes rite, i missed the part about ajax. Go with what LuckyFella73 said (but my logic will hold true in a non-ajax/two forms on one page scenario).