How to change the text on a button progamatically? |
(01-08-2018, 10:52 PM)Wouter60 Wrote: Your question tells me that you didn't read the CI tutorial: http://www.codeigniter.com/userguide3/tu...index.html I have read that and am well aware of how URL's pass parms in CI. I use it all over my app. This is more of a question of sending data from a controller function to a view. Here is what I have in a function in my controller; $data = array('campaign' => $campaign); $str = $this->db->update_string('users', $data, $where); $this->db->query($str); //set active to 1 $iRc = $this->input->post($campaign); //THIS IS THE LINE THAT DOESN'T WORK The first 3 lines update the database and this seems to work fine. The last line is the problem. I want to send the campaign name to the jquery that is now running in the view. Here is the head section of the view: <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <link href="/assets/css/screen.css" rel="stylesheet" type="text/css" /> <!-- the following two lines load the jQuery library and JavaScript files --> <script src="/assets/js/jquery-1.4.2.js" type="text/javascript"></script> <script src="/assets/js/global.js" type="text/javascript"></script> /* Global JavaScript File for working with jQuery library */ $.when().then{ var elem = document.getElementById('myCamp'); elem.text = campaign; } </head> Finally, here is the defintion of the button: <button id="myCamp" class="btn pull-right btn-danger navbar-btn ">Active Campaign: None</button> I am not sure what $.when does? I probably need to loop and wait until that post() in the controller has an updated campaign label. Or wait for a "post event'. So the two parts a) sending the string b) waiting for the string are my issue. I am only going in one direction: from controller to view. thanks for your help, btw
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |