Welcome Guest, Not a member yet? Register   Sign In
How to change the text on a button progamatically?
#5

(This post was last modified: 01-08-2018, 11:56 PM by richb201.)

(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
Please do! It gives you an idea how URL's in CI work.
You can't run a URL that refers to a view, model, library etc. CI expects a controller name and a method name (function) inside that controller, optionally followed by one or more parameters.
Like: http://website_base_url/controller_name/...am2/paramn}
Routes are a way to manipulate that, but you'll first need to understand the basics.

I'll come back later to give you an example of AJAX.

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
Reply


Messages In This Thread
RE: How to change the text on a button progamatically? - by richb201 - 01-08-2018, 11:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB