CodeIgniter Forums
Javascript !! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Javascript !! (/thread-28342.html)



Javascript !! - El Forum - 03-08-2010

[eluser]Shaileen[/eluser]
Hi guys,

can you please tell me how can i implement javascript in my view?

below is the self defined function to check users information in javascript that i want to implement in CI...


if (document.forms[0].eu_address.value.length ==0){
alert('Please enter the End User Address.')
return false}
if (document.forms[0].eu_city.value.length ==0){
alert('Please enter the End User City.')
return false}


Javascript !! - El Forum - 03-08-2010

[eluser]ciGR[/eluser]
You can implement the js code in your view into

Code:
<scipt type='text/javascript'></scipt>
tags
Or you can write your code into a seperate js file, like mycode.js and create for example the below file stracture:

Code:
|-- assets
    |-- js
        |--mycode.js
|-- system
|-- index.php

and call it in your view with
Code:
<scipt type = 'text/javascript' src = '&lt;?php echo base_url(); ?&gt;/assets/js/mycode.js'></scipt>


P.S. I write above scipt instead script because for security reasons, forum remove the script tags.