JavaScript - Help With Grabbing A File Name
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 Similar TutorialsWhile on vacation I've been writing a bunch of javascript/css text effects for fun and I'm planning to look into how I can implement my code inside a url. So now I want to know how I can recognise and grab the text from any random webpage and put it inside of a variable, my script can take it from there.
Alright, so I'll be honest, I HAVE NO IDEA ABOUT JAVASCRIPT! So, basically, I want, when the button is clicked, for this to grab some levels from a game and do some calculations. Simple. Well... Not for me. Here is the code I have right now: Code: <script language="JavaScript" type="text/javascript"> function GrabTheStats(rsusername){ var GrabStats = ""http://hiscore.runescape.com/index_lite.ws?player="" + rsusername; var GrabStats_array = GrabStats.split(","); attLvl = expToLevel(GrabStats_array[0],false); strLvl = expToLevel(GrabStats_array[1],false); defLvl = expToLevelGrabStats_array[2],false); hpLvl = expToLevel(GrabStats_array[3],true); magLvl = expToLevel(GrabStats_array[4],false); ranLvl = expToLevel(GrabStats_array[5],false); praLvl = expToLevel(GrabStats_array[6],false); sumLvl = expToLevel(GrabStats_array[7],false); calcResult = calcCombat(attLvl,strLvl,defLvl,hpLvl,magLvl,ranLvl,praLvl,sumLvl); document.getElementById('outputlocation').value = calcResult[0] + "/" + calcResult[1]; } </script> Code: <input type="text" name="outputlocation" id="outputlocation"/> <input type="button" onclick="GrabTheStats("zezima");" value="CLICK ME" /> Could someone help me to get this working? The calcCombat calculates things bases on the levels it grabs and produces an array of results, calcResult[0] and [1] being the two results I want right now. An example output will hopefully be "95/98". Please don't criticize, since this is for 'crappy old RuneScape'. It really doesn't help. Thanks! Bit of a noob when it comes to js. Hope someone can help me out. I am trying to place text output from a url on another webpage. The output is the status of an alarm system. The URL is: Code: https://www.eye-zon.com/EZMOBILE/index.php?mid=<hash>&action=ssi&did=<mac> hash and mac info remove for security reasons. The URL leads to a webpage that outputs: Code: <update>2011-08-18 21:21:10</update><status> Stay Armed </status><trouble>NO</trouble> I would like to place these three outputs on another page. Any ideas? Hello all, Im new to the board, Have a question i cant figure out. This board seems very helpful, so here goes. Im trying to grab certain variables like orderID & Subtotal variables that are posted to the confirmation page. The reason im grabbing these is for a confirmation pixel that is displayed for commission junction. When some clicks on their link, then completes an order, their tracking pixel fires grabs these variables and that way they can track the order confirmaton. The problem is they dont see the tracking pixel firing and its not grabbing the variables. I dont know what to do. Here is the code. maybe someone here can help me?? This is the code that shows on the confirmation page. Im assuming this is where im suppose to grab the variables. Code: //<![CDATA[ var SecureCartOrders = [ {"orderID":154983165,"name":"Max Test","company":null,"email1":"max@maxtest.com","address1":"123 main st","address2":null,"city":"miami","state":"Florida","zip":"33845","country":"United States","fax":null,"phone":"5611112222","secondaryphone":null,"cardtype":"","shipname":"Max Test","shipCompany":null,"shipAddress1":"123 main st","shipAddress2":null,"shipCity":"west palm beach","shipState":"Florida","shipZip":"33405","shipCountry":"United States","status":"Accepted","product":["oil product"],"sku":["FC1246"],"quantity":[1],"price":[0.00],"option":[[]],"productattributes":[{}],"plist":"3598071","Total":0.00,"shippingMethod":"Free Shipping","shippingAmount":0,"grandTotal":0.00,"adtrack":0} ]; //]]> This is the javascript code that im using to grab those variables. The variables that i need are orderID & Total Code: <script type='text/javascript'> var orderId = SecureCartOrders[0].orderID; var subTotal = SecureCartOrders[0].Total; var url ='https://www.emjcd.com/u?CID=111111&TYPE=343000&CURRENCY=USD&METHOD=IMG'; url += '&OID=' + orderId; url += '&AMOUNT=' +subTotal; document.write('<img width=\'20\' height=\'1\' src=\' + url + \'\'>'); </script> I have no idea what else i can do. This is a system hosted confirmation page from a shoppingcart software called, 1shoppingcart.com 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(); } } Hi, 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> 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 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); }); }); } 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); 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 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? Is this doable using Javascript? Basically i just need (if there is one) a Javascript version of PHP include ("the/file.php");
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.. 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 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, 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 |