⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Using javascript to update an on screen field with GC



richb201

richb201
  • profile picture
  • Member

Posted 06 January 2018 - 21:19 PM

I have to admit, I am getting frustrated. My app development is moving along well except for a few small things. One BIG problem is that I can't run javascript. Yes, I have read the documentation (perhaps 10 times) and yes, I see the set_js(), and yes I have created a js file and placed it in assets/script/js. But I can't seem to get it to run. Or more precisely, I can't find a demo up here of a controller, a callback, a call to a javascript function. Perhaps you guys have done this so many times that it is obvious. But it is not to me. What is more frustrating is that the javascript class (which has better documentation and I have relied on  a lot) has been deprecated in CI with a big note DO NOT USE.  

 

I am not even sure exactly what I want to run in javascript; once I get js running I will figure that part out. I know that I need to change the word NONE on the blue background to a user defined word. I have tried creating a js file that contains this ONLY:

 

$(document).ready(function(){
$("button").click(function(){
$("myCamp").remove();
});
});

 

 

This is not actually what I want to do but I needed to make sure I can get the js to run.  The idea was to  create a button that would remove the myCamp element (on the blue background). I put in the "button" but when i click on it, the .js file doesn't run.  I have also tried putting js in a callback but it won't run either. Perhaps I need to change something in config to run .js? I am actually more expert at the subject matter than coding :rolleyes: . 

 

Anyway, as I have mentioned before up here, I am willing to pay for some help. I don't need a huge amount of help, btw. Just some dedicated counsel on a few places where I am stuck.  We can do a paypal payment to pay you for your time, which is only fair, IMO. 


richb201

richb201
  • profile picture
  • Member

Posted 06 January 2018 - 22:16 PM

I have also tried using this PHP code in my controller. 

 

$output $crud->render();

$dom=new DOMDocument();

$dom->loadHTML($output->output);
$dom->validateOnParse = true;
$img_nodes=$dom->getElementById('myCamp');

 

But when I look at the $dom->textContent for the word NONE, it is missing. 


Stephenmerchant

Stephenmerchant
  • profile picture
  • Member

Posted 29 January 2018 - 04:49 AM

This isn't really what I need to do yet I expected to ensure I can get the js to run. The thought was to make a catch that would evacuate the camp component (on the blue foundation). I put in the "catch" however when I tap on it, the .js record doesn't run. I have additionally had a go at placing js in a callback however it won't run either. Maybe I have to change something in the config to run .js? I am in reality more master at the topic than coding Essay Service UK