![]() |
Unable to throw my hidden input to Controller - 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: Unable to throw my hidden input to Controller (/showthread.php?tid=44276) |
Unable to throw my hidden input to Controller - El Forum - 08-10-2011 [eluser]Wondering Coder[/eluser] hi guys, I'm having a bit problem here. It seem I can't throw my hidden input to my controller. It return blank T_T. this is my view Code: <?php Code: $item = $this->uri->segment(3); and this is the output of my query Code: SELECT user_id, a.data_id, fullname, username, pps_c.data_display, a.display,fname,mname,lname FROM (SELECT ad_userid user_id, ad_dataid data_id,concat_ws(' ',fname,mname,lname) as fullname, ad_username username, display,fname,mname,lname FROM pps_admin_users UNION SELECT user_id, data_id,concat_ws(' ',fname,mname,lname) as fullname, username, display,fname,mname,lname FROM pps_users) a LEFT JOIN pps_dataset pps_c ON a.data_id=pps_c.data_id WHERE user_id = 12 AND data_id = ORDER BY a.data_id ASC As you can see my data_id = '' //blank. Can anyone help me with this.. Unable to throw my hidden input to Controller - El Forum - 08-10-2011 [eluser]jblack199[/eluser] to me it looks like some html formatting issues... in the code, it seems to all start at this line: <a >user_id."' class='"; which is an apparent syntax error. as in you're in the end missing a " because of the improper HTML. also your else statement is missing a { giving you an improper else clause... and the HTML at: echo "'><input type='hidden' name='role' value='".$item->data_id."'/></a></td> is also wrong, this one i dont know what you're trying to do with that first echo, and the closing link tank after the hidden input so i cant give you any info to fix that. despite all that, i'm sure someone at some point will say: tables ewww so lets get that one out of the way now. Unable to throw my hidden input to Controller - El Forum - 08-10-2011 [eluser]jblack199[/eluser] Just reread your HTML, i rewrote it from scratch -- try it and see what happens. Apparently, because I havent purchased any software or something I cant post 'links' so change all the f href's to the correct syntax otherwise it really wont work. Code: <?php Unable to throw my hidden input to Controller - El Forum - 08-10-2011 [eluser]boltsabre[/eluser] Yeah, I'd imagine it's got to do with putting an input field (in your case the hidden one) inside an anchor tag. Your <a> tag is all over the place, it has no href=""..., it has not 'link text' between the opening and closing <a> tags.... I'm guessing your trying to pass the $item->data_id as an identifier so when the user clicks on the link some action happens, but only for that particular $data_id..??? You'll have to append/concatenate this variable to your href attribute and then in your controller extract it using $this->uri->segment(whatever segment your $data_id is). Or make a new form inside your foreach loop for each item, and use a hidden field to populate this value... I think you may be trying to combine both methods together, and that's where your getting into trouble. Unable to throw my hidden input to Controller - El Forum - 08-10-2011 [eluser]Wondering Coder[/eluser] actually I solved it. Also its not a typo problem in my part. Somehow when I copy paste and posted my code in here, the output changes., haha. Also I think I undestand why it's not throwing the hidden field value to my controller its bcoz I'm not using <form></form> just a regular <a></a> link. So what I did to solve this is by throwing the value in my url. e.g.: <a ></a>' Unable to throw my hidden input to Controller - El Forum - 08-10-2011 [eluser]boltsabre[/eluser] Well yes... if you output a hidden (or any form field for that matter) and it's not inside <form> tags with an action/method then it is not going to do anything!!! HTML 101 ;-) Glad to hear you got it solved by attaching the value to your anchor tag like I suggested. If this is solved, can you please edit the title to reflect this so others know everything is fixed! Thanks champ. |