Can someone help about form_dropdown() and onChange() in CodeIgniter |
[eluser]Unknown[/eluser]
Hi everybody!! I a newbie for CodeIgniter. I would like to ask all you guys. I have to table in databases, tb_customer and tb_customer_site. Firstly, I query customer name to show in first drop-down list (as below code). I want to do that once I select customer name, system should query site name for that customer and show in the second drop-down list without refresh page. I understand that I can use onChange() in 4th parameter of form_dropdown(). I already test by alerting some text but It dose not work. ##My controller Code: //Query CUS_CODE and CUS_NAME from TB_CUSTOMER ##My view Code: <? Thank you your kind. ^^
[eluser]boltsabre[/eluser]
Try escaping your second double quotes " like this: Code: $js = 'onChange="alert(\\\\"Hello World\");"'; Without escaping it you are basically telling it that it ends here: Code: onChange="alert(" That MAY fix your problem, I'm at work and don't have an installation of CI here to test it on. Also, did you get any JS errors? Or other errors? I use firefox for production as I like it's range of developer tools (plugins), use this one (see link below) to easily see JS errors. click on the cross to see what the error is. Once you have it installed the very top right hand corner it's tool bar has 3 ticks or crosses (or a combination, but always 3), the very right one is for JS... if you have a tick you have no obviously JS code errors, but if you get a cross then yep, something's wrong. Obviously you don't have to use FF or it's extensions, but it's my preference. Another great one if Firebug if you're not already using it (you can google that link yourself if you want it). https://addons.mozilla.org/en-US/firefox...developer/ Good luck with it.
[eluser]Unknown[/eluser]
Thank for your prompt reply. Yes!! you are correct that there is something wrong on my JS because there is red crosses on the top right. But as I check is said "" Code: Error: SyntaxError: illegal character I already change as your comment Code: $js = 'id="mrtgCusName" onChange="alert(\\"Hello World\");"'; Thank! |
Welcome Guest, Not a member yet? Register Sign In |