freshbee Posted February 13, 2009 Share Posted February 13, 2009 Dear Friends, Can I write a function in php which includes all the javascripts. And call that function wherever necessary. Ex : [pre]class USER { public function include_js_files() { echo "<script language=javascript src=../scripts/IsValid.js></script>"; echo "<script language=javascript src=../scripts/IsAlpha.js></script>"; echo "<script language=javascript src=../scripts/IsEmail.js></script>"; } public function edit_user($user_id,$role_id) { self::include_js_files(); ..... echo "<form id=1 onsubmit='return chk_input();' method=post action='edit.php'>"; ..... ..... } }[/pre] Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/145036-including-the-java-script/ Share on other sites More sharing options...
Prismatic Posted February 13, 2009 Share Posted February 13, 2009 You can, just make sure it gets inserted into the <head></head> of your document Link to comment https://forums.phpfreaks.com/topic/145036-including-the-java-script/#findComment-761099 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.