JavaScript - Javascript Code Not Working When I Upload It
So I have a file that factors quadratics.
It works just fine when I open the file from my desktop, but when I upload it and try to use it, the javascript stops working. Any ideas? This is the file: http://wdroom.com/factor.html You can try it out there, or you can download it. I can't get it to work at all for some reason... Thanks! Similar TutorialsI am trying for a javascript code that would ask for the excel file location when run, fetch data from two columns till eof in an excel file (MS Excel 2010), append it to an existing text file and upload the plain text file to an ftp location. The ftp username, password and location needs to be hard coded in the script. Is this possible? This is suppose to execute "avalon" and it should move down the page once and "Books" should move with it, hidden behind it. I have read the code over and over and over and do not see any mistakes. HELP! Code: <title>Avalon Books</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <script src="scripts.js" type="text/javascript"></script> <script type="text/javascript"> function placeObjects() { placeIt("avalon",175,10); placeIt("books", 175,10); placeIt("ab",230,40); placeIt("fiction",5,5); placeIt("nfiction",475,5); hideIt("ab"); hideIt("fiction"); hideIt("nfiction"); moveAvalon(); } function moveAvalon() { var y=yCoord("avalon"); if (y <= 260) { shiftIt("avalon",0,10); shiftIt("books",0,10); setTimeout("moveAvalon()",30); } else { moveBooks(); } } function moveBooks() { var x=xCoord("books"); if (x <= 320) { shiftIt("books",10,0); setTimeout("moveBooks()",50); } else { //display the hidden images; } } </script> </head> <body onload="placeObjects()"> <div id="avalon"> AVALON </div> <div id="books"> BOOKS </div> <div id="ab"> <a href="#"> <img src="ab.jpg" alt="Click to enter store" /> </a> </div> <div id="fiction"> <img src="fiction.jpg" alt="" /><br /> <b>AB Sales Rank: #1<br /> Fiction</b><br /> <i>Before the Fall</i><br />Jeffrey Unwin </div> <div id="nfiction"> <img src="nfiction.jpg" alt="" /><br /> <b>AB Sales Rank: #1<br /> Nonfiction</b><br /> <i>Vietnam Memoirs</i><br />Gen. John Hartford </div> </body> </html> I havent even declared x,y and z as variables! Code: x=10; y=20; z = x+y; document.getElementById('good').innerHTML=z; I am getting so confused... since the time i started learning JS i thought declaring variables (var x,y,z was real important! Can't get this to work...could someone read thru this and see if anything is missing? Thanks Code: <html> <head> Supporting files: lhouse.css, list.js, logo.jpg <title>The Lighthouse</title> <link href="lhouse.css" rel="stylesheet" type="text/css" /> <script src="list.js" type="text/javascript"></script> <script type="text/javascript"> function amountTotal() { total(0); for (var i=0; i<=amount.length; i++) { total+=amount[i]; } return total; } </script> </head> <body> <div id=title> <img src=logo.jpg alt=The Lighthouse /> The Lighthouse<br /> 543 Oak Street<br /> Delphi, KY 89011<br/> (542) 555-7511 </div> <div id=data_list> <script type="text/javascript"> document.write("<table border=1' rules=rows cellspacing=0'>"); document.write("<tr><th>Date</th><th>Amount</th><th>First Name</th><th>Last Name</th><th>Address</th></tr>"); for (i=0; i< amount.length; i++) { if (i%2==0) document.write("<tr>"); else document.write("<tr class='yellowrow'>"); document.write("<td>"+date[i]+"</td>"); document.write("<td class=amt>"+amount[i]+"</td>"); document.write("<td>"+firstName[i]+"</td>"); document.write("<td>"+lastName[i]+"</td>"); document.write("<td>"); document.write("<td>"+street[i]+"<br/>"); document.write("city[i],+" +state[i]+ "+zip[i]"); document.write("</td>"); document.write("</tr>"); } document.write("</table>"); </script> </div> <div id=totals> <script type="text/javascript"> document.write("<table border=1' cellspacing=1'>"); document.write("<tr><th id=sumTitle colspan=2'>Summary</th></tr>"); document.write("<tr><th>Contributors</th>"); document.write("<td>+amount.length+</td></tr>"); document.write("<tr><th>Amount</th>"); document.write("<td>$+amountTotal()+</td></tr>"); document.write("</table>");</script> </div> </body> </html> </html> I have a webpage where I have declared a variable as Code: <input type="hidden" id="Edits_OK" /> I set the value of this variable within a Javascript function to either "T" or "F". In my code-behind, I have a btnSubmit_Click() event that calls this Javascript function. In this code-behind event, I also check the value of the "Edits_OK" variable, however, the value is always "". The Javascript function will always put a value in this variable whether it's "T" or "F". I also declare the "Edits_OK" variable within the code-behind as this: Code: Private Edits_OK As New HiddenField Here is the Javascript Function. Code: function CheckEdits() { var msg; document.getElementById("Edits_OK").value = 'T'; if (document.getElementById("txtName").value == '') { msg = msg + '\nName'; document.getElementById("Edits_OK").value = 'F'; } if (document.getElementById("txtOrganization").value == '') { msg = msg + '\nOrganization'; document.getElementById("Edits_OK").value = 'F'; } if (document.getElementById("txtSubject").value == '') { msg = msg + '\nSubject'; document.getElementById("Edits_OK").value = 'F'; } if (document.getElementById("txtNote").value == '') { msg = msg + '\nNote'; document.getElementById("Edits_OK").value = 'F'; } if (document.getElementById("Edits_OK").value == "F") { var msg2; msg2 = "Please provide the following information:\n"; error_occurred = true; alert(msg2 + msg); } } Here is the code-behind Procedu Code: Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Try If Edits_OK.Value = "T" Then FormatEmail() End If Catch ex As Exception lblErrMsg.Text = "btnSubmit_Click() Event - " & ex.Message End Try End Sub Not sure why the value is always "". Please help! Thanks! Hey guys-I realize that this is a javascript/php hybrid, but I am having a strange problem here. Basically, this script uploads an image (from another page), then allows you to crop it and save it. I want to have it redirect back to the original page in the form of a php header (see if $_GET['action']==done). However, it doesn't seem to want to send the header! This is strange because my first header, right above the second, that redirects to an error page, works just as planned. Here is the code. The headers I've added are very close to the top. Code: <?php /* * Copyright (c) 2008 http://www.webmotionuk.com * "PHP & Jquery image upload & crop" * Date: 2008-05-15 * Ver 1.0 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * http://www.opensource.org/licenses/bsd-license.php */ if ($_GET['action']=="done") { if ($_POST['x1']=="" || $_POST['y1']=="" || $_POST['x2']=="" || $_POST['y2']=="" || $_POST['w']=="" || $_POST['h']=="") { header("Location: profile.php?action=cropError"); } } if ($_GET['action']=="done") { header("Location: profile.php"); } session_start(); $userid = $_SESSION['userid']; //Constants //You can alter these options $upload_dir = "uploadPic"; // The directory for the images to be saved in $upload_path = $upload_dir."/"; // The path to where the image will be saved $large_image_name = $userid."full.jpg"; // New name of the large image $thumb_image_name = $userid."thumb.jpg"; // New name of the thumbnail image $max_file = "100000"; // 100KB $max_width = "500"; // Max width allowed for the large image $thumb_width = "175"; // Width of thumbnail image $thumb_height = "234"; // Height of thumbnail image //Image functions //You do not need to alter these functions function resizeImage($image,$width,$height,$scale) { $newImageWidth = ceil($width * $scale); $newImageHeight = ceil($height * $scale); $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight); $source = imagecreatefromjpeg($image); imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height); imagejpeg($newImage,$image,90); chmod($image, 0777); return $image; } //You do not need to alter these functions function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){ $newImageWidth = ceil($width * $scale); $newImageHeight = ceil($height * $scale); $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight); $source = imagecreatefromjpeg($image); imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height); imagejpeg($newImage,$thumb_image_name,90); chmod($thumb_image_name, 0777); return $thumb_image_name; } //You do not need to alter these functions function getHeight($image) { $sizes = getimagesize($image); $height = $sizes[1]; return $height; } //You do not need to alter these functions function getWidth($image) { $sizes = getimagesize($image); $width = $sizes[0]; return $width; } //Image Locations $large_image_location = $upload_path.$time.$large_image_name; $thumb_image_location = $upload_path.$time.$thumb_image_name; //Create the upload directory with the right permissions if it doesn't exist if(!is_dir($upload_dir)){ mkdir($upload_dir, 0777); chmod($upload_dir, 0777); } //Check to see if any images with the same names already exist if (file_exists($large_image_location)){ if(file_exists($thumb_image_location)){ $thumb_photo_exists = "<img src=\"".$upload_path.$thumb_image_name."\" alt=\"Thumbnail Image\"/>"; }else{ $thumb_photo_exists = ""; } $large_photo_exists = "<img src=\"".$upload_path.$large_image_name."\" alt=\"Large Image\"/>"; } else { $large_photo_exists = ""; $thumb_photo_exists = ""; } if (isset($_POST["upload"])) { //Get the file information $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $filename = basename($_FILES['image']['name']); $file_ext = substr($filename, strrpos($filename, '.') + 1); //Only process if the file is a JPG and below the allowed limit if((!empty($_FILES["image"])) && ($_FILES['image']['error'] == 0)) { if (($file_ext!="jpg") && ($userfile_size > $max_file)) { $error= "ONLY jpeg images under 100KB are accepted for upload"; } }else{ $error= "Select a jpeg image for upload"; } //Everything is ok, so we can upload the image. if (strlen($error)==0){ if (isset($_FILES['image']['name'])){ move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width){ $scale = $max_width/$width; $uploaded = resizeImage($large_image_location,$width,$height,$scale); }else{ $scale = 1; $uploaded = resizeImage($large_image_location,$width,$height,$scale); } } //Refresh the page to show the new uploaded image header("location:".$_SERVER["PHP_SELF"]); exit(); } } if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists)>0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width/$w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale); //Reload the page again to view the thumbnail header("location:".$_SERVER["PHP_SELF"]); exit(); } if ($_GET['a']=="delete"){ if (file_exists($large_image_location)) { unlink($large_image_location); } if (file_exists($thumb_image_location)) { unlink($thumb_image_location); } header("location:".$_SERVER["PHP_SELF"]); exit(); } if($_GET['action']=="done"){ include('functions.php'); dbconnect(); $query = "UPDATE user SET picture='$thumb_image_name' WHERE userid='$userid'"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query"); $_SESSION['picture'] = $thumb_image_name; header( "refresh:0;url=profile.php" ); } include('top.php'); ?> <!-- * Copyright (c) 2008 http://www.webmotionuk.com / http://www.webmotionuk.co.uk * Date: 2008-05-15 * Ver 1.0 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * http://www.opensource.org/licenses/bsd-license.php --> <?php //Only display the javacript if an image has been uploaded if(strlen($large_photo_exists)>0){ $current_large_image_width = getWidth($large_image_location); $current_large_image_height = getHeight($large_image_location);?> <script type="text/javascript"> function preview(img, selection) { var scaleX = <?php echo $thumb_width;?> / selection.width; var scaleY = <?php echo $thumb_height;?> / selection.height; $('#thumbnail + div > img').css({ width: Math.round(scaleX * <?php echo $current_large_image_width;?>) + 'px', height: Math.round(scaleY * <?php echo $current_large_image_height;?>) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); $('#x1').val(selection.x1); $('#y1').val(selection.y1); $('#x2').val(selection.x2); $('#y2').val(selection.y2); $('#w').val(selection.width); $('#h').val(selection.height); } $(document).ready(function () { $('#save_thumb').click(function() { var x1 = $('#x1').val(); var y1 = $('#y1').val(); var x2 = $('#x2').val(); var y2 = $('#y2').val(); var w = $('#w').val(); var h = $('#h').val(); if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){ alert("You must make a selection first"); return false; }else{ return true; } }); }); $(window).load(function () { $('#thumbnail').imgAreaSelect({ aspectRatio: '175:234', onSelectChange: preview }); }); </script> <?php } ?> <?php //Display error message if there are any if(strlen($error)>0){ echo "<ul><li><strong>Error!</strong></li><li>".$error."</li></ul>"; } if(strlen($large_photo_exists)>0){?> <img src="<?php echo $upload_path.$large_image_name;?>" style="float: left; margin-right: 10px;" id="thumbnail" alt="Create Thumbnail" /> <div class="cropInstructions"> <?php if ($_GET['action']=="done") { echo "<h3>Picture Updated!</h3>"; } ?> <h3>Crop Profile Picture</h3><p>To crop the photo, simply click your mouse on the picture to the left and drag it to the desired size.</p> <br style="clear:both;"/> <form name="thumbnail" action="cropImage.php?action=done" method="post"> <input type="hidden" name="x1" value="" id="x1" /> <input type="hidden" name="y1" value="" id="y1" /> <input type="hidden" name="x2" value="" id="x2" /> <input type="hidden" name="y2" value="" id="y2" /> <input type="hidden" name="w" value="" id="w" /> <input type="hidden" name="h" value="" id="h" /> <input type="hidden" name="done" value="yes" id="done" /> <input type="submit" name="upload_thumbnail" value="Save Thumbnail" class="cropButton" /> </form><br> <a href="profile.php">Back To Edit Profile</a> </div> <?php } include('bottom.php'); ?> <!-- Copyright (c) 2008 http://www.webmotionuk.com --> </body> </html> hi there, i have a problem which is there is some javascript codes keeping the #usemap tag from working here is my webpage Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta content='text/html; charset=windows-1256' http-equiv='Content-Type' /> <title>Assiut map</title> <script src="shiftzoom.js" language="javascript" type="text/javascript"></script> <script type="text/javascript"> <!-- if(document.images&&document.createElement&&document.getElementById){ document.writeln('<style type="text/css">'); document.writeln('img.shiftzoom { visibility: hidden; }'); document.writeln('<\/style>'); } shiftzoom.defaultCurpath = 'images/cursors/'; //--> </script> </head> <body> <div id="content"> <div style="float: left; width:700px; height:300px; border:1px solid gray; margin-right: 1em; margin-bottom: 0.25em;"> <div style="width:700px; height:300px; background: url(images/indicator.gif) 50% 50% no-repeat;"> <img id="map" usemap="#map" class="shiftzoom" onLoad="shiftzoom.add(this,{showcoords:false,zoom:100});" src="assiut.jpg" width="700" height="300" alt="large image" border="0" /> </div></div></div> <map name="map" id="map"> <area shape="circle" coords="250,160,15" href="#nowhere" title="Ahmed house<br>name:ahmed<BR>Class:1-1" alt="" /> <area shape="circle" coords="110,164,15" href="#nowhere" title="Mohamed house<br>name:Mohamed<BR>Class:2-1" alt="" /> <area shape="circle" coords="190,362,15" href="#nowhere" title="Mostafa house<br>name:Mostafa<BR>Class:3-1" alt="" /> </map> </body> </html> the .js file in attachments which have somthing that keeps the #usemap from working, would be so thankful if anyone could help thanks I hope I have this post in the right place! Any help would be very much appreciated... I have a feature on my website that allows users to choose the website background (using alternate css sheets) and then uses an externally linked javascript file to store the background choice as a cookie so it is consistent throughout the website. This works perfectly locally (i.e. when previewing my website on my computer) but now it is uploaded to my host it doesn't appear to be working. (with the same browser) My javascript is he http://www. b r p - e n v .com/javascript/backgroundchange.js (with no spaces) The website that the javascript file is linked to is http://www. b r p - e n v .com (with no spaces) In the head I have: <script type="text/javascript" src="../javascript/backgroundchange.js"></script> ...then I have: <body onload="set_style_from_cookie()"> ...and for users to choose which background: <form> <input type="image" src="../images/white-background-thumb.jpg" onclick="switch_style('bg1');return false;" name="theme" value="White" id="bg1"> etc... </form> My problem is: The background reverts back to the default when moving to a different page. This would indicate that the background choice is not being saved in cookies. But this works locally! I have tried putting the javascript directly onto each page but I still had the same problem. I hope someone can help, I will be so grateful if I can get this to work. Many thanks indeed! Hey everyone here is my code for looking up a city, and state by zip code. I am getting no errors and i believe it should work, but the code does not seem to want to function. Any ideas? Here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>City and State Lookup</title> <style type="text/css"> h1 { font-family:Arial; color:navy; } p, td { font-family:arial; font-size:11px; } </style> <script type="text/javascript"> /* <![CDATA[ */ var httpRequest = false; function getRequestObject() { try { httpRequest = new XMLHttpRequest(); } catch (requestError) { try { httpRequest = new ActiveXObject ("Msxm12.XMLHTTP"); } catch (requestError) { try { httpRequest = new ActiveXObject ("Microsoft.XMLHTTP"); } catch (requestError) { window.alert("Your browser does not support AJAX!"); return false; } } } return httpRequest; } function updateCityState() { if (!httpRequest) httpRequest = getRequestObject(); httpRequest.abort(); httpRequest.open("get","zip.xml"); httpRequest.send(null); httpRequest.onreadystatechange=getZipInfo; } function getZipInfo() { if (httpRequest.readyState==4 && httpRequest.status == 200) { var zips = httpRequest.responseXML; var locations = zips.getElementsByTagName("Row"); var notFound = true; for (var i=0; i<locations.length; ++i) { if (document.forms[0].zip.value == zips.getElementsByTagName( "ZIP_Code")[i].childNodes[o].nodeValue) { document.forms[0].city.value = zips.getElementsByTagname( "City") [i].childNodes[0].nodeValue; document.forms[0].state.value = zips.getElementByTagName( "State_Abbreviation")[i].childNodes[0].nodeValue; notFound = flase; break; } } if (notFound) { window.alert("Invalid ZIP code!"); document.forms[0].city.value = ""; document.forms[0].state.value = ""; } } } /* ]]> */ </script> </head> <body> <h1>City and State Lookup </h1> <form action=""> <p>Zip code <input type="text" size="5" name="zip" id="zip" onblur="updateCityState()" /></p> <p>City <input type="text" name="city" /> State <input type="text" size="2" name="state" /></p> </form> </body> </html> Hi there, I have a File Upload tool and would like to prevent the users from clicking on the textbox to upload files. Also, I want to disallow the manual entering of file pathname. How should I edit it? I would need to use Javascript. <input type="file" name="attachment" id="attachment" style="width:300px" /> Please help ... bit urgent I am creating a small automated system where front-end is html query form and back-end database is MS excel. both at local PC only & in a single folder. problem is like a survey form. continuous data entry, error correction, read/wite all these are included. I created a program upto first entry; but the second, third, ... entries and it is continuous. pl help me regards K.Kaniraj Hi there, I would like to know how I can show the line "Attach another File" right away, instead of what is depicted in my own code of showing it after a file has been attached. Also, I would like to align "Attach another File" to the right, so that the word "file" will be below the Browse button. 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>Untitled Page</title> <script language="javascript" type="text/javascript"> var upload_number; function addFileInput() { var d = document.createElement("div"); var file = document.createElement("input"); file.setAttribute("type", "file"); file.setAttribute("name", "attachment"+upload_number); d.appendChild(file); document.getElementById("moreUploads").appendChild(d); upload_number++; } </script> </head> <body> <input type="file" name="attachment" id="attachment" onchange="document.getElementById('moreUploadsLink').style.display = 'block';" /> <div id="moreUploads"></div> <div id="moreUploadsLink" style="display:none;"><a href="javascript:addFileInput();">Attach another File</a></div> </body> </html> hereis the html file and javascripton click of this button a html ***************************** <table class=matcolor id=topnav cellspacing=0 cellpadding=0 width=550 border=0 bgcolor="#FFCCCC"> <tbody> <tr align=middle> <td id=menu1 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Desk Top Publishing </font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu2 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Transcription</font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu3 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Accounts Processing </font></div> </td> </tr> </tbody> </table> ***************************************** <script language=JavaScript> ix = document.getElementById('tblmenu1').getBoundingClientRect(); new ypSlideOutMenu("menu1", "right",ix.left + ix.right ,ix.bottom + 10); </script> **any thing i have to alter to work in firefox please help Hi everybody, I have this File Upload control, whereby the user is granted a limit of 5 uploads. And so, the user clicks on "Attach Another File", and decides to attach a file ONLY in the first File Upload control. My problem is, I want the user to be able to click on an "X" beside every File Upload control, so that it will close those unnecessary (or unused) FIle Upload controls. How do I edit my code in JAVASCRIPT? Please advise. 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></title> <script language="javascript" type="text/javascript"> var fileCount = 1; function addOneFile() { ++fileCount; var div = document.getElementById("showFile"+fileCount); if ( div != null ) div.style.display = "block"; } </script> <style type ="text/css"> .style37 { color: Black; margin-left: 99px; } </style> </head> <body> <table cellpadding="5"> <tr> <td style="vertical-align: top"> Attachment: </td> <td> <input type="file" name="attachment" id="attachment" style="width:230px" /> <div id="showFile2" style="display: none;"> <input name="file2" type="file" /> </div> <div id="showFile3" style="display: none;"> <input name="file3" type="file" /> </div> <div id="showFile4" style="display: none;"> <input name="file4" type="file" /> </div> <div id="showFile5" style="display: none;"> <input name="file5" type="file" /> </div> <br /> <a href="javascript:addOneFile();" class="style37">Attach another File</a> <br /> (Restricted to 5 uploads) </td> </tr> </table> </body> </html> I'm attempting to pull the hidden iframe file upload trick using javascript. I've go my form file upload and iframe fine, but I can't figure out what to do when it gets server side. There seems to be relatively no documentation on how to handle uploaded files in server-side javascript. Ideas? I'm at a loss.
I wrote a script that should loop through the list of countries, and if the entry's width exceeds 70px, it should cut the extra letters and insert "..." at the end of the entry; My codes produces unexpected results. The script only modifies the entry"United States", by replacing it with "Cook Isla...". I suspect I don't use the while loop properly. Plus the script does not work at all in IE. Could someone have a look and give me a hint what went wrong. Thank you very much!!! Code: <html> <head> <title> Ellipse Practice </title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <style type="text/css"> ul { width: 200px; margin-left: 100px; } span { white-space: nowrap; } </style> <script type="text/javascript"> function trancateAll() { var list=document.getElementsByTagName("li"); count=0; while (count<list.length) { var text=String(list[count].innerHTML); list[count].innerHTML='<span id="mySpan">'+text+'</span>'; mySpan=document.getElementById("mySpan"); mySpan.innerHTML=''; var charac=1; while( (mySpan.offsetWidth<70) && (charac<text.length)) { mySpan.innerHTML=text.substr(0,charac)+"..."; charac++; } count++; } } </script> </head> <body > <ul> <li> United States</li> <li> Australia</li> <li> New Zealand</li> <li> Democratic Republic of Congo</li> <li> Russian Federation</li> <li> Cook Islands</li> </ul> <input type="button" value="Truncate" onclick="trancateAll()"/> </body> </html> Hey guys, I am not sure why this JavaScript is not working. Can you check it out please? Thanks. --Start-- <html> <head> <title>Guess it up! </title> </head> <body> <center> <b><font size="5" ><u><b>Guess it up!<br></b></u> <br > <font size="3" > This is out of five! <br > Type in your guess: <p> </p> </font> <input name="HisGuess" type="text" size=1 value=1> <p> <input name="StartButton" type="button" value="Guess" onclick="StartGame()"> </p> <p> <script> var TheRightNumber = Math.round(Math.random * 5); function StartGame() { if (TheRightGuess == HisGuess){ alert("You got it! Nice!") else{ alert("Guess again!") } } </script> --END-- Can anyone tell my why this is not working? All answers are appreciated. Hey all, I have a javascript object which I have created and it works fine until I remove the second message box from the program steps. The alert box was only ever meant to be there for error debugging to steop me through the code. Any ideas? Code: function hyper() { this.test = ""; this.load = function(lib, ver) { alert("Starting API Library Load"); var oHead = document.getElementsByTagName('HEAD').item(0); var oScript= document.createElement("script"); oScript.type = "text/javascript"; oScript.src=lib + "/" + ver + "/api.js"; oHead.appendChild( oScript); alert("Finished Loading Library"); switch(lib) { case "test": this.test = new test(); break; case "ads": this.ads = new HAds(); break; case "chat": this.chat = new HChat(); break; case "survey": this.survey = new HSurvey(); break; default: alert("No Library"); }; } } Any idea why this doesn't work? I'm trying to hide the li with ID of facebook1 if the innerHTML is one of two things. But if both return false and there is more code in there (e.g. a full url), I want to show the li with ID of facebook1 and also add the text 'Facebook Profile' to the span with ID of fbook-add. Code: <ul> <li id="facebook1"><a href="http://facebook.com"><span id="fbook-add"></span></a></li> </ul> <script type="text/javascript"> if(document.getElementById('facebook1').innerHTML.toLowerCase()=='<a href="http://"><span id="fbook-add"></span></a>') { document.getElementById('facebook1').style.display='none'; } else if(document.getElementById('facebook1').innerHTML.toLowerCase()=='<a href=""><span id="fbook-add"></span></a>') { document.getElementById('facebook1').style.display='none'; } else { document.getElementById('fbook-add').innerHTML=='Facebook Profile'; } </script> |