JavaScript - Loada Php File Into A Div
Is this doable using Javascript? Basically i just need (if there is one) a Javascript version of PHP include ("the/file.php");
Similar TutorialsHi, Can someone tell me what I am doing wrong. Script works on the first attachment but not the other two? Code: <script type="text/javascript" language="JavaScript"><!-- function ExtensionsOkay() { var extension = new Array(); var fieldvalue = new Array(); fieldvalue[0] = document.customApp.attachment_1.value; fieldvalue[1] = document.customApp.attachment_2.value; fieldvalue[2] = document.customApp.attachment_3.value; extension[0] = ".doc"; extension[1] = ".docx"; extension[2] = ".txt"; extension[3] = ".pdf"; // No other customization needed. for(var f = 0; f < fieldvalue.length; f++) { var thisext = fieldvalue[f].substr(fieldvalue[f].lastIndexOf('.')); for(var i = 0; i < extension.length; i++) { if(thisext == extension[i]) { return true; } } alert("Your upload field " + f + " contains an unapproved file name."); return false; } } //--></script> I can get this code to take two separate sections of a file which are not beside each other and write them into another file. It always comes up as a single full line of the code instead of the sections I want. The code includes the student number first name last name and three results of assignments. I want the code to write the student number and three results of all the students into a file and then work out the average of the student results. Can you help? Code: try{ while (in.hasNextLine()) { String line = in.nextLine(); out.println( line); int i=0; if(!Character.isDigit(line.charAt(i))) { i++; } studentStringNumber = line.substring(0, i); String stringResult = line.substring(i); studentStringNumber = studentStringNumber.trim(); stringResults = stringResults.trim(); double stringResultsValue = Double.parseDouble(stringResults.trim()); stringResults = in.nextLine(); studentStringNumber = in.nextLine(); studentNumber = Integer.parseInt(studentStringNumber); if(in.hasNextInt()) { int value = in.nextInt(); } results = Double.parseDouble(stringResults); if(in.hasNextDouble()) { double value = in.nextDouble(); } Scanner lineScanner = new Scanner(line); studentStringNumber = lineScanner.next(); while(!lineScanner.hasNextDouble()) { studentStringNumber = studentStringNumber+ " " +lineScanner.next(); } stringResultsValue = lineScanner.nextDouble(); } } Does anyone know how to accomplish this? I got the html file to show but none of the text in the file will show.
Hello all, I am new here and have a question about a AP Div I am using as a dropin. It drops in when the page loads and I would like it to only drop in if a visitor clicks a link I designate as the dropin link. Can someone please tell me how to accomplish this? I am pasting in the js file and I will also need to know how to set up the "a href" link to call the dropin! Thanks is advance for any help you may give! Code: // JavaScript Document var ie=document.all var dom=document.getElementById var ns4=document.layers var calunits=document.layers? "" : "px" var bouncelimit=32 //(must be divisible by 8) var direction="up" function initbox(){ if (!dom&&!ie&&!ns4) return crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin scroll_top=(ie)? truebody().scrollTop : window.pageYOffset crossobj.top=scroll_top-250+calunits crossobj.visibility=(dom||ie)? "visible" : "show" dropstart=setInterval("dropin()",50) } function dropin(){ scroll_top=(ie)? truebody().scrollTop : window.pageYOffset if (parseInt(crossobj.top)<100+scroll_top) crossobj.top=parseInt(crossobj.top)+40+calunits else{ clearInterval(dropstart) bouncestart=setInterval("bouncein()",50) } } function bouncein(){ crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits if (bouncelimit<0) bouncelimit+=8 bouncelimit=bouncelimit*-1 if (bouncelimit==0){ clearInterval(bouncestart) } } function dismissbox(){ if (window.bouncestart) clearInterval(bouncestart) crossobj.visibility="hidden" } function truebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } window.onload=window.setTimeout(initbox,5000); Hi i am using javascript for the first time and i have a problem .I have 2 files html and javascript file in seperate but i donot know how to make them work .the code is down below .Thanks in advance for help. HTML <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <meta name="description" content="Instagram API - usage" /> <meta charset=utf-8 /> <title></title> </head> <body> <input id="lat_input" type="number" value="60.221374"/> <input id="lng_input" type="number" value="24.805391"/> <button id="search_location">Search</button><br/> <button id="get_popular">Get popular</button> <div id="images"></div> </body> </html> Javascript file // API DOCUMENTATION: // Instagram Developer Documentation var clientId = 'e7538f47e197479d8d32a63ae3ae4cd2'; $('#search_location').click(function () { getMediaByLocation($('#lat_input').val(), $('#lng_input').val()); }); $('#get_popular').click(function () { getPopularImages(); }); function getMediaByLocation(lat, lng) { var o = { lat: lat, lng: lng, client_id: clientId }; $.getJSON('https://api.instagram.com/v1/media/search?callback=?', o, function (response) { processImages(response.data); }); } function getPopularImages() { var o = { client_id: clientId }; $.getJSON('https://api.instagram.com/v1/media/popular?callback=?', o, function (response) { processImages(response.data); }); } function processImages(array) { $('#images').empty(); $.each(array, function (index, element) { var fs = $('<fieldset>').appendTo('#images'); $('<img>').attr('src', element.images.low_resolution.url).appendTo(fs); if (element.caption) { $('<pre>').text(element.caption.text).appendTo(fs); } $.each(element.comments.data, function (index, comment) { $('<pre>').text('Comment from ' + comment.from.full_name + ': ' + comment.text).appendTo(fs); }); }); } All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero help me! im have 2 file .js file 1.js code: document.write("<script src=2.js></script>") document.write(f) file 2.js code: var f="hello" im want run 1.js get variable of file 2.js by 3.html but don't run! code 3.html <script src=1.js></script> I tried to follow directions here http://www.javascriptkit.com/javatut...ernalphp.shtml and here http://codingforums.com/showpost.php...91&postcount=4 without any luck. Data is looked up from a MySQL database via .php file and then I want javascript inserted into the .js file which includes the data from the query lookup in the .php file. If I load the .php file - everything looks good. But nothing shows in the .js file. Below is the contents of the .php file which is located at http://blackburnseminars.com/wp-cont...is_prices.php: Code: <?php //PHP SCRIPT: get_regis_prices.php header('Content-type: application/x-javascript'); //connect to database mysql_connect("localhost","username","password"); //(host, username, password) //specify database mysql_select_db("dbname") or die("Unable to select database"); //select which database we're using $str="\r"; //CRLF $result = mysql_query("select * from table_name"); while ($row = mysql_fetch_object($result)) { echo "document.write(var fee = \"\";)".$str; echo "document.write(if (studentTypeAbbrev == \"A\"))".$str; echo "document.write({)".$str; echo "document.write(if (creditHours==1) fee =" . $row->atty_crs1.";)".$str; echo "document.write(if (creditHours==3) fee =" . $row->atty_crs3.";)".$str; echo "document.write(document.write(if (creditHours==6) fee =".$row->atty_crs6.";)".$str; echo "document.write(})".$str; echo "document.write(else if (studentTypeAbbrev == \"P\"))".$str; echo "document.write({)".$str; echo "document.write(if (creditHours==3) fee =" . $row->para_crs3.";)".$str; echo "document.write(if (creditHours==6) fee =" . $row->para_crs6.";)".$str; echo "document.write(})".$str; echo "document.write(else if (studentTypeAbbrev == \"J\"))".$str; echo "document.write({)".$str; echo "document.write(fee =" . $row->judge.";)".$str; echo "document.write(})".$str; } ?> The .js file has this line inserted where I want the javascript from the .php file to go: Code: <script type="application/x-javascript" src="http://blackburnseminars.com/wp-content/themes/blackburn/get_regis_prices.php"></script> ...but the code from the .php file doesn't show when I load the .js file. Can anyone tell me what I am doing wrong? Also, do I need to enclose the lines inside document.write()? - (I'm not clear on that) Thanks much Tom Esker Dear All I have a .js file in which i have pasted Urdu text and HTML tags like function urdutext() { innerHTML.right_column='HTML tags & urdu text';} The .js file contains about eighty lines of urdu text and some HTML tags in betweeen. But when i run this file alone in my browser it displays half of the file and the rest of the lines remain undisplayed. and when i use this file in my web page and when i click a button to display the urdu text, it dispays nothing in my web page. I know the reason but i cant solve it my self. The reason is that the .js file does not get fully uploaded and hence the file remains open and the syntax become wrong. And that is the reason it does not display anything in the web page. So i want ut help. Any one can help and would take my best wishes. Regards Sajad Bhatt I've tried every combination I can think of, and I can't figure this out. According to me, if you type a name that matches one of the xml items' names into the box using the following code: Code: Name: <input type="text" id="nameInput"/> <input type="button" onclick="searchLocations()" value="Search Locations"/> function searchLocations() { var input = document.getElementById('nameInput').value; if (!input) { alert("please enter a name"); } else { for (var j = 0; j < gmarkers.length; j++) { if (gmarkers[j].myname == input) { gmarkers[j].show(); } } } } it should show the gmarker with that name... but nothing. If I leave it blank and hit the search button at least I get the alert, so something is working... any suggestions? hi guys.. i have a problem.. first i have a about_us.php page.. which inside the about_us page i include right banner page.. using php include.. and this right banner page height must be the same height as the about_us page.. so i need using js to get the actually about_us page height and send to right_banner page so i can process it.. my logic are get the div height from about_us page.. send it to right_banner page.. and using php to process it,so the right banner height can be similar to about_us page when about_us page open by user.. about_us.php i using div input all the stuff Code: <div class="mainarticel">text goes here </div> and mainarticle css i put in outside css.. called style.css nb:mainarticle height i using auto; and in right_banner page i using Code: function getHeight (id) { var gh = document.getElementById(id).offsetHeight; alert (gh);} but this cannot get the div from another file.. so how can i get the div height from another file? hi, I am a newbie. Using Java script, I need to open and read CSV file. I need to read the third column values and store in an array. Please help me regarding this. Thanks, Hanumanth. i noticed today that if i type in my js file name in the url i get a download box, i have an htaccess on my site so this should not be happening, thats another issue.. my question is, is there a trick to creating a js file that cant be accessed in this manner, i was thinking about adding a php define statement as it comes from one source only, but i wanted to ask first to see if there was something on the js side i could do or is that strictly a htaccess or server side issue.. In a php upload Form when a User chooses an image file to upload, the name of the file appears next to the Choose File button (see attachment) is it possible to grab that file name, add it to the page, and proceed with completing the Form? Attached Thumbnails hello .. can I use som function from c++ library in my java script file ? thanks .. I am trying to grab the file name of an image generated by a PHP file. I first tried loading the image in an iframe, letting it load, and then grabbing the src; but IE and Fx security measures denied me access to both the src and the href of the iframe. Then, I tried storing the iframe in an object variable after loading and reading the src / href of the variable, but it was always null. Finally, I decided to replace the iframe with an image tag...and it actually started to work. I could access the src after the image had loaded! The only problem is...it is giving me the original src, when what I want is the src generated by the php file that I am using as the image src. As a last personal attempt, I stored the image tag into an Image object, and then used the name method to try and get the file name of the image inside of the tag, but again...that is just returning the src of the php file. Here is where the code is loading: http://avatars.imvu.com/GetInfo Can anyone tell me how to get the file name of an image? Code: <script type="text/javascript"> var UserID=''; var aviName=''; var aviPicBegin = 'http://www.imvu.com/catalog/web_av_pic.php?av='; var aviPicFull=''; var aviPic2=''; var myIMG = imgDisplay; function input() { aviName = fInput.txtAviName.value; aviPicFull = aviPicBegin + aviName; document.getElementById('imgDisplay').src=aviPicFull; } function display() { myIMG = imgDisplay; //aviPic2 = imgDisplay.src; //myIMG.src = aviPic2; alert("img src = " + myIMG.src); //userID=; // document.fOutput.txtID.value = userID; //document.fOutput.txtHP.value = ""; //document.fOutput.txtBlock.value = ""; //document.fOutput.txtAdd.value = ""; //document.fOutput.txtReport.value = ""; } </script> <center> <FORM name=fInput> Avi Name: <input type="text" name="txtAviName"></input><br/><br/> <input type="button" name="Operation" value="Get Info" OnClick="input();"></button> </FORM> <br/> <br/> <img src="/catalog/web_av_pic.php?av=GetInfo" id="imgDisplay" width="160px" height="220px" scrolling="no" padding="0" MARGINWIDTH="0" OnLoad="display();"></img> <br/><br/> <FORM name="fOutput"> ID: <input name="txtID"></input><br/> HP: <input name="txtHP"></input><br/> Block: <input name="txtBlock"></input><br/> Add: <input name="txtAdd"></input><br/> Report: <input name="txtReport"></input> </FORM> <br/><br/> </center> Thanks to everyone who took the time to read this. Hi, I am trying to open a FTP file in IE 6, but Its not opening, it throws "Page cannot be Displayed" message. Its work fine in Firefox. Below is the code: <A href="ftp://sysvine.lmt.com/reports/chart.doc">Category Chart</A> even I tried like this: <A href="ftp://username:password@sysvine.lmt.com/reports/chart.doc">Category Chart</A> Please let me know if there is any workaround. Regards, Selvin I am recieving an error of Access Denied in a HTA file when the self.ResizeTo is called in the following code on Line 59 any help would be great. <html> <title>Personal Folder Creator</title> <HTA:APPLICATION ID="objPersonalFolderCreator" APPLICATIONNAME="PersonalFolderCreator" WINDOWSTATE="normal" > <head> <style> BODY { font-family: verdana; font-size: 8pt; } H2 { color: blue; } .Table { font-size: 10pt; border-width: thin; border-style: solid; padding: 10px; } .ResultsTable { border-width: thin; border-style: solid; font-size: 8pt; } </style> '******************************************************************** '* BEGIN_SCRIPT '******************************************************************** <script language="vbscript"> Option Explicit Dim objShell, objFSO Dim strServer, strPath strServer = "TWB-FLS-PR-01" strPath = "Personal" Sub Window_Onload Set objShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") ParentFolder.Disabled = True SubmitButton.Disabled = True PopulateParentFolders self.Focus() self.ResizeTo 720,410 UserID.Focus() End Sub Sub PopulateParentFolders Dim objFolder, objTempFolder, strTempPath strTempPath = "\\" & strServer & "\" & strPath Set objFolder = objFSO.GetFolder(strTempPath) For Each objTempFolder In objFolder.SubFolders Dim objoption Set objOption = Document.CreateElement("OPTION") objOption.Text = objTempFolder.Name objOption.Value = objTempFolder.Name ParentFolder.Add(objOption) Next End Sub Sub LookupButton_OnClick() Dim objUser Set objUser = GetObject("WinNT://PRDS/" & UserID.Value) lblUserName.innerText = objUser.FullName If InStr(lblUserName.innerText, "(") > 0 Then lblSubFolder.innerText = Mid(lblUserName.innerText, 1, InStr(lblUserName.innerText, "(") - 1) ElseIf InStr(lblUserName.innerText, "[") > 0 Then lblSubFolder.innerText = Mid(lblUserName.innerText, 1, InStr(lblUserName.innerText, "[") - 1) End If ParentFolder.Disabled = False SubmitButton.Disabled = False LookupButton.Disabled = True UserID.Disabled = True lblStatus.innerHTML = "Select Parent Folder - DEFAULT is PERSONAL." End Sub Sub SubmitButton_OnClick() Dim strCommand Dim intReturn If objFSO.FolderExists(lblTargetFolder.innerText) Then MsgBox "Folder Already Exists!", vbExclamation lblStatus.innerHTML = "<font color='red'>Folder Already Exists.</font>" Exit Sub Else If MsgBox("Create the Personal Folder:" & vbNewLine & lblTargetFolder.innerText, vbYesNo + vbQuestion) = vbNo Then Exit Sub End If End If objFSO.CreateFolder(lblTargetFolder.innerText) strCommand = "SUBINACL /file """ & lblTargetFolder.innerText & """ /perm /grant=Administrators=F /grant=SYSTEM=F /grant=PRDS\sor-A-Admins=F /grant=PRDS\" & UserID.Value & "=C /setowner=Administrators" intReturn = objShell.Run(strCommand, 7, True) If intReturn <> 0 Then MsgBox "Error modifying permissions on folder: " & lblTargetFolder.innerText,vbExclamation Else SubmitButton.Disabled = True ParentFolder.Disabled = True MsgBox "Personal Folder Created and Permissions have been set accordingly." & vbNewLine & "Advise Customer the Path to their Personal Folder.", vbInformation lblStatus.innerHTML = "<font color='green'>Folder Created Successfully.</font>" End If End Sub Sub ResetButton_OnClick() ParentFolder.Disabled = True SubmitButton.Disabled = True LookupButton.Disabled = False UserID.Disabled = False ParentFolder.Value = "NUL" lblUserName.innerText = "" lblSubFolder.innerText = "" lblTargetFolder.innerText = "" UserID.Value = "" UserID.Focus() lblStatus.innerHTML = "Enter User ID and Click Lookup." End Sub Sub ParentFolder_OnChange() If ParentFolder.Value = "NUL" Then lblTargetFolder.innerText = "" lblStatus.innerHTML = "Select Parent Folder." Else lblTargetFolder.innerText = "\\" & strServer & "\" & strPath & "\" & ParentFolder.Value & "\" & lblSubFolder.innerText lblStatus.innerHTML = "Ready to Create Folder." End If End Sub </script> '**************************************************************************** '* END_SCRIPT '**************************************************************************** </head> '**************************************************************************** '* HTML Section '**************************************************************************** <body> <h2 align="center">Personal Folder Creator - TWB-FLS-PR-01</h2> <table id='tblInput' class='Table' width="670"> <tr><td><b>User ID: </b></td><td rowspan="2"><input type='text' name='UserID' size='10'><button name='LookupButton'>Lookup</button> <p><select name='ParentFolder'><option value='NUL'>Select</option></select></td> <td rowspan="2"> </td><td rowspan="2" width="324"> <img border="0" src="http://sor-app-pr-01:78/_layouts/images/IT_support.gif" width="324" height="103"></td></tr> <tr><td><b>Parent Folder: </b></td></tr> </table> <br/> <table id='tblSummary' class='Table' width="670"> <tr><td><b>User Name: </b></td><td><div id='lblUserName'> </div></td></tr> <tr><td><b>Personal Folder: </b></td><td><div id='lblSubFolder'> </div></td></tr> <tr><td width='15%'><b>Target Folder: </b></td><td width='85%'><div id='lblTargetFolder'></div></td></tr> <tr><td><b><font color="#FF0000">Status:</font> </b></td><td><font color='red'><div id='lblStatus'>Enter User ID and Click Lookup.</div></font></td></tr> </table> <br/> <div align="left"> <table id='tblButtons' class='Table' style="border-style: solid"> <tr><td> <p align="center"><button name='SubmitButton'> <p align="left">Create Folder</button></td><td> <p align="center"><button name='ResetButton'>Reset</button></td><td> <p align="center"><button name='ExitButton' onClick='self.Close()'>Exit</button></td></tr> </table> </div> <br/> Version 1.1(SOR) : Last Modified 11-08-2008 by Steve Dudley : ITO SOR <br/> Version 1.0 : Created on 04-01-07 by Adam Rutt : ISB DTSG </body> </html> hi my website is in php . am using a javascript code to open a file . Code: function dec() { window.open("www.test.com/files/2010/test.pdf"); } when i click the hyperlink connected to this function , a browser window is opened .path to the file will be dispaled in the address bar i dont want it like tat. i need to open only the file test.pdf , not in browser window so that path will not be seen . pls help. hi my website is in php . am using a javascript code to open a file . Code: function dec() { window.open("www.test.com/files/2010/test.pdf"); } when i click the hyperlink connected to this function , a browser window is opened .path to the file will be dispaled in the address bar i dont want it like tat. i need to open only the file test.pdf , not in browser window so that path will not be seen . pls help. |