JavaScript - Include Php Files Using Javascript?
So, I have a dynamic PHP file on my server. I want to make it so browsers can take the code I provide and paste it in an .html, .php, or .asp file, and it'll display across the board.
The file would need to be included, unless someone thinks there's a better way of doing this? The only example I could think of would be Google Adsense's code? But I'm not sure. Similar TutorialsI've now go to the point of wanting to include one javascript file within another. I was hoping for something analagous to: PHP Code: include("myfile.php"); But there isn't any built-in way of doing that?! I can see that it would be a security issue if you could include JS from anywhere - but surely it wouldn't be a problem if you could only include scripts on the same host as the including script? Greetings! I included this script in my php mysql query result. test.php Code: <html> <head> <title></title> <script type = 'text/javascript'> function addRow() { tabBody=document.getElementById("inputtable"); row=document.createElement("TR"); cell1 = document.createElement("TD"); cell2 = document.createElement("TD"); cell3 = document.createElement("TD"); cell4 = document.createElement("TD"); cell5 = document.createElement("TD"); cell6 = document.createElement("TD"); textnode1=document.createElement("input"); textnode1.name="accnum[]"; textnode1.type="text"; textnode2=document.createElement("input"); textnode2.name="copy[]"; textnode2.type="text"; textnode3=document.createElement("input"); textnode3.name="locate[]"; textnode3.type="text"; textnode4=document.createElement("input"); textnode4.name="funds[]"; textnode4.type="text"; textnode5=document.createElement("input"); textnode5.name="stat[]"; textnode5.type="text"; textnode6=document.createElement("input"); textnode6.name="remarks[]"; textnode6.type="text"; cell1.appendChild(textnode1); cell1.appendChild(textnode2); cell1.appendChild(textnode3); cell1.appendChild(textnode4); cell1.appendChild(textnode5); cell1.appendChild(textnode6); row.appendChild(cell1); row.appendChild(cell2); row.appendChild(cell3); row.appendChild(cell4); row.appendChild(cell5); row.appendChild(cell6); tabBody.appendChild(row); } </script> </head> <body> <form> <table> <tbody id="inputtable"> <tr><td> <input type = 'text' name = 'accnum[]' placeholder = 'Accession number' /> <input type = 'text' name = 'copy[]' placeholder = 'Copies' /> <input type = 'text' name = 'locate[]' placeholder = 'Book Location' /> <input type = 'text' name = 'funds[]' placeholder = 'Source fund' /> <input type = 'text' name = 'stat[]' placeholder = 'Status' /> <input type = 'text' name = 'remarks[]' placeholder = 'Remarks' /> </tbody> </table> <br/> <input type="button" value="Add new" onclick="addRow();" /></td></tr> <br/><br/> <input type = 'submit' name='submit' value = 'Submit'/> </form> </body> </html> PHP Code: $query2 = mysql_query("SELECT * FROM tbl_bacquisition WHERE bd_Id = '$bdID'") or die (mysql_error()); while ($row2 = mysql_fetch_assoc($query2)) { echo $row2['ba_Accnum'].' '.$row2['ba_Copynum'].' '.$row2['ba_Section'].' '.$row2['ba_Sfunds'].' '.$row2['ba_Status'].' '.$row2['ba_Remarks'].'<br/>'; } } echo '<br/>'; include 'test.php'; My problem is that my script is not performing its job, it adds row when the button is clicked. But when I tried to other page, it works. Any help would be so much appreciated. Is it possible to use Javascript to dynamically change the PHP file used for an include? For example, if I have a php doc like Code: <html> <body> <div>other stuff</div> <div> <?php include('onefile.php'); ?> </div> <div>more other stuff</div> </body> </html> I can get Javascript to remove the included stuff, but I can't figure out how to change the <?php include('onefile.php'); ?> into <?php include('otherfile.php'); ?>. What would be the best way to do that? I included a js file into my html file. Everything work well in firefox but intenet explorer does not display my js file content. please helppp Js file // JavaScript Document document.write(<div class="RightSideGallerybox"> <div class="RightBoxContext">News</div> <div class="RightBoxPictures"><img src="../image/BotanicalTreeDecoration.jpg" /></div> <div class="RightBoxPictures"><img src="../image/IMG_3304.JPG" /></div> <div class="RightBoxPictures"><img src="../image/IMG_0297.JPG" width="150" height="100" /></div> <div class="ImportantRemarks">High School Admissions</div> <div class="ListOfRemarks"> <ul> <li>A. Phillip Randolph HS</li> <li>Astor Collegiate</li> <li>Aviation High School</li> <li>Bard College HS</li> <li>Bayside High School</li> </ul> </div> </div>); html file <div class="RightSideWrap"> <div class="footertext"> <script type="text/javascript" src="gallery.js"></script> </div> <!-------------------------------middle parts - right side--------------------------> </div> </div> My site loads too many javascript files and it takes much time to load page. I would like to reduce the number of http requests and combine all javascript files into one file. What is the best way for it? Will it work if I just copy whole code from all files and paste into one or anything else is needed? Thanks I have an external Javascript file that only works when I put: Code: <script type="text/javascript" src="external.js"></script> at the end of the HTML page. Does anyone know why it won't work in the head of the page? Thanks Howdy all. I have Win 7, IE9. I have a HTML file on my hard drive, with Javascript within. When I load the page, it keeps popping up Do u want to allow this content, I have to click to allow. I want to stop this, and after doing some searching I found the setting in Internet Options, Advanced - "Allow active content to run in files on my computer". Perfect. Doesnt work. When i check this box, the page loads without the warning, but then the Javascript just doesnt work. Getting quite annoying, because this file is my home page. Any help would be great! hi all, i'm a relatively new user to javascript. i'm supposed to use javascript to search through a folder that contains many excel files. the search term is obtained from a front end html form, javascript gets that value, search every single excel file in the folder and see which file has a cell that matches the search terms. I currently know (sort of) how to search through 1 file. but how do I search through many files? and from what i see from the searching of 1 file, it takes a few seconds to open and close the excel file (located on a network drive). which means it will take a fair bit of time to cycle through 97 excel files. Is there like any searching algorithm to speed up the process? I am doing a program to teach pre-schoolers on how to use the keyboard. If there any possible if I press the arrow up key, It will then show a excellent swf, that I have make. if wrong if will come out try again swf using javascript. please help me. im stuck. Hi all- I currently use a javascript seacrh string on my website that searchs all folders (directories) and gives results on a html page. My problem is that some folders (or sub directories) are not being found when I type into the form search box. Does anyone know why this might be happening? here is the script im using <script language="JavaScript" type="text/javascript">function OnSearchSubmit(){var b_return=true;if (document.form_search.sw){for(var i=0;i<document.form_search.sw.value.length;i++){if (document.form_search.sw.value.charAt(i)!=" ") {lh="searchresult.html?sw="+encodeURIComponent(document.form_search.sw.value);b_return=false;break;} }}if (b_return) return;window.open(lh,"_self");}</script> thanks! I want to use HTML5's audio coding similar to the one below: Code: var audioElement = document.createElement('audio'); audioElement.setAttribute('src', 'horse.ogg'); audioElement.play(); In order to play sound files depending on the input. What I'm working on is a text-to-speech webapplication. What I'd need to happen is for there to be an input and then allow the user to type anything into the input, so if they type in: Hello, how are you doing? Javascript or PHP will recognize each character and translate it into an audio sequence. In example: It'd detect the "H" in hello and play sound file "H.ogg" It'd then detect the "E" in hello and play sound file "E.ogg" I know there must be an easy way to do this. Could somebody help me please to explain what I'm doing wrong.... a have this html file with references to some javascripts (datagrid from http://www.datatables.net) and this html file work ok..I mean javascripts a css styling works with table... but when I call this page by ajax and callback (this html page) is forward back into another div , table doesn't work ....just data from page but now functionality from javascript and css styling... how should I force callback result to use javascript and css? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="Content-type" content="text/html; charset=UTF-8"> <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/media/images/favicon.ico"> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.datatables.net/rss.xml"> <style type="text/css" media="screen"> @import "media/css/demo_page.css"; @import "media/css/demo_table.css"; @import "http://www.datatables.net/media/css/site_jui.ccss"; @import "media/css/demo_table_jui.css"; @import "media/css/themes/base/jquery-ui.css"; @import "media/css/themes/smoothness/jquery-ui-1.7.2.custom.css"; /* * Override styles needed due to the mix of three different CSS sources! For proper examples * please see the themes example in the 'Examples' section of this site */ .dataTables_info { padding-top: 0; } .dataTables_paginate { padding-top: 0; } .css_right { float: right; } #example_wrapper .fg-toolbar { font-size: 0.8em } #theme_links span { float: left; padding: 2px 10px; } </style> <script type="text/javascript" src="media/js/complete.js"></script> <script src="media/js/jquery-1.4.4.min.js" type="text/javascript"></script> <script src="media/js/jquery.dataTables.min.js" type="text/javascript"></script> <script type="text/javascript" src="media/js/jquery.dataTables.editable.js"></script> <script src="media/js/jquery.jeditable.js" type="text/javascript"></script> <script src="media/js/jquery-ui.js" type="text/javascript"></script> <script src="media/js/jquery.validate.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> $(document).ready( function () { $('#example').dataTable().makeEditable({ sUpdateURL: "update.php", sDeleteURL: "delete.php" }); } ); </script> </head> <body id="index" class="grid_2_3"> <table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> <thead> <tr> <th> ID</th> <th> user</th> <th> password</th> <th> first</th> <th> last</th> <th> company</th> </tr> </thead> <tbody> <tr class="even_gradeA" id="1"> <td> 1 </td> <td> XY </td> <td> passwoed </td> <td> Ja </td> <td> jajovic </td> <td> 2 </td> </tr> <tr class="even_gradeA" id="2"> <td> 2 </td> <td> jojo </td> <td> fa25af5301e2dda1fddea740200aa10ab6c70d86 </td> <td> jojo </td> <td> jojovicko </td> <td> 2 </td> </tr> <tr class="even_gradeA" id="3"> <td> 3 </td> <td> kuk </td> <td> d588aebb93e3adf70eac1fb479d6d53f9dc21816 </td> <td> kuk </td> <td> kukovic </td> <td> 3 </td> </tr> <tr class="even_gradeA" id="10"> <td> 10 </td> <td> admin </td> <td> f865b53623b121fd34ee5426c792e5c33af8c227 </td> <td> admin </td> <td> adminovic </td> <td> 3 </td> </tr> </tbody> </table><button id="btnDeleteRow">Delete</button> </body> </html> I have been working on a few budget scripts that I can access from the web in using HTML. My problem is that when variable values change I need to change these values in all of the HTML files on the server. I know that there is a way to declare global variables in a single file and use those values in another file but I have not been able to find any information that tells me exactly how to do this. I have tried to put it together on my own using what little informaiton I have been able to find but have not been able to get this to work. Is there a more detailed referance that I can find somewhere or does anyone know what steps I need to take to make this happen?
Does anyone know how to accomplish this? I got the html file to show but none of the text in the file will show.
Hi all. The below script is from suckerfish. Can anyone help me include a 'one sec delay' to keep the menu open onmouseout. First menu often closes too fast before I get a chance to move onto submenu. I've tried everything with setTimeout BUT I just can't get it right. Nothing I do works. Can somebody PLEASE show me so I can kick myself. LT Code: <script type="text/javascript"><!--//--><![CDATA[//><!-- sfHover = function() { var sfEls = document.getElementById("nav").getElementsByTagName("LI"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" sfhover"; } sfEls[i].onmouseout=function(){ this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); } } } if (window.attachEvent) window.attachEvent("onload", sfHover); //--><!]]></script> Ok I want to be able to include a html file into my template. I want the php include to work when I press a button that will put the include into a specific element with the document.getElementById("").innerHTML method in javascript. I want the include to be able to be more then a single line. For example I want to be able to write my code like this <div> some text </div> and not have to write it like this <div>some test</div> Thanks Shelby Hi I am in the middle of building some API's for my site and have built a cernal for all API's to read but i dont want the user to add two script tags to their sites code so I was wondering how I could do this. These are not my real files but will give you the full view of what it is I am trying to do. - cernal.js Code: var error = function(o) { if(o !== '') { alert(o); } }; - pub109283746374.js Code: // include the cernal.js file here somehow // Do a small function that uses the error cernal function function ShowNotice() { if(API_KEY !== '' && API_KEY !== undefined) { alert('Success'); } else { error('Sorry but you have an invalid API key.'); } } - http://www.userswebsite.com/demoFile.html Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>WHOISearch API Demo</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://www.mysite.com/API/pub109283746374.js"></script> </head> <body> <script type="text/javascript"> //<![CDATA[ ShowNotice(); // Alerts 'Sorry but you have an invalid API key.' //]]> </script> <script type="text/javascript"> //<![CDATA[ API_KEY = 'pub109283746374'; ShowNotice(); // Alerts 'Success' //]]> </script> </body> </html> If anyone can help me it will help me so much with finishing these API's, please reply if you know how I can do this, Thank You. DJCMBear Hi guys, I've found tooltip I want to include in one of pages, and I'd appreciate your help. http://code.drewwilson.com/entry/tiptip-jquery-plugin I'm having troubles in finding a way to display it. Here is how I made it on this demo page : http://www.air.vlexo.net/tiptip/ I'm not sure what I did wrong, so please help me figure it out. Thanks in avance. Hi all, I cant get this code to work because I do not know how to include the % character. Any help would be appreciated. My line break isnt working either Cheers, Adrian Code: rightButton.innerHTML = (rightOutcome1Prob+" chance of "+rightOutcome1+"\r\n else "+rightOutcome2); |