JavaScript - File Pointing Issue
Hello Everyone...
I'm VERY new to JS and trying to learn using a program that creates menus with Flash and JS. With the below code, my flash menu works when the files are in the same directory as the code, however, I cannot figure out how to make it work when I have the XML,Flash,JS files located in another directory. Could someone give me idea what I must first look at. I believe I have tried the obvious areas in the code, but they have not worked. Thanks ! <script type="text/javascript" src="stfmenu.js"></script> <p><a href="http://www.menu-flash.com" style="display:none;visibility:hidden;"> Flash Menu</a></p> <script type="text/javascript"> <!-- st_siteroot="" st_swfpath="menu.swf"; o={} o.position="static"; o.clear ="both"; o.width ="1"; o.height = "1"; o.left = "1"; o.top = "1"; o.id = "Adin"; if(!window.location.href.indexOf("file:") && st_swfpath.charAt(0)=="/") o.src = st_siteroot+st_swfpath; else o.src = st_swfpath; o.vars="flashid=Adin&menuId=0&dirPath=&siteRoot="; document.write(SFMGetFlashHTML(o)); //--> </script> Similar TutorialsHi all ! I have written code for select options one. In that option one of the option is to select others. When i select others automatically the cursor should goto others text area box. Any suggessions please. 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Smartcard Gen2</title> <link rel="stylesheet" type="text/css" href="style.css"/> <script type="text/javascript" charset="utf-8"> var notEmpty=function(){ document.write("Problem Submitted, Thank You"); window.open(list.html); } </script> </head> </head> <body> <div class="container">, <div class="topbar"> <p>Report a Problem<a href="list.html" class="button back black"><span></span> ATM Details</a></p> </div> <div class="content"> <h6>Find ATMs by Address:</h6> <div class="box"> <table width="95%" border="0" align="center" cellpadding="8" cellspacing="0"> <tr> <td width="33%" align="right" valign="middle"><strong>Problem :</strong></td> <td> <FORM ACTION="#" NAME=latin> <SELECT NAME="words" > <option value="ATM NOT PRESENT">ATM not present</option> <option value="ATM IS BROKEN">ATM Broken</option> <option value="MASTERCARD IS NOT ACCEPTED">ATM doesnot accept MasterCard</option> <option value="ATM IS NOT ACCESSIBLE">ATM is not accessible</option> <option value="others" id="others">Others</option> </select> </FORM> </td> </td> </tr> </table> <div class="box"> <table width="95%" border="0" align="center" cellpadding="8" cellspacing="0"> <tr> <td width="33%" align="right" valign="middle"><strong>Other :</strong></td> <td width="67%" align="left" valign="top"><input name="textfield3" type="textarea" rows="25" coloumns="15" id="textfield3" placeholder=" " /></td> </tr> </table> </div> <a href="#" class="transactions" onclick="notEmpty();">Submit</a></div> </div> </body> </html> I'm trying to code something in batch and i need some help... I need to change the batch files dir to the only folder in the next folder IE: move from folder 1 to folder 2 contents of folder 1: folder 2 however i don't know the real name of folder 2 so I need batch file to like pick the folder by its number or something.... is there a solution(i would like to code this in batch) I have an Extjs web app that's running on a spring/rest backend & I'm having a really strange caching issue with my web app's javascript files & no-one seems to be able to tell what it is. The issue is that I have deleted a section of code in the JS file, yet it's still appearing in the browser, both IE and FF. I have tried a number of solutions but nothing has worked. if anyone has any suggestions as to what the issue would be, I would appreciate it. What I have tried: Manually remove & re-add the file Rollback the file to a previous version Remove the file from the index.html and re-add it Clear all cache in FF & IE Disable firebug Check the script is updated by manually accessing the file via the application URL & Firebug Script tab Renaming the JS file Renaming the index.html file Cleaning/rebuilding/removing the project Restarting the server & eclipse Pointing the server to a different location Rebooting Removing & re-adding the Tomcat server Ctrl + F5 Checking the URL path/classpath in Eclipse is correct Removing all Temp Internet Files (including when all associated apps were closed) Adding Pragma no-cache metadata tag to the index.html I'm at a loss as to what could be causing it. Hi everyone so ive been doing some searching on how to save textarea content as a file and found ... Code: http://www.codingforums.com/showthread.php?t=32077 Saving works ok but the issue I have is that when you enter some text and hit the submit button the content of the page becomes the content within the the file your saving check demo so you can see for yourself: Code: http://6d8.info/demo.html So what I need is for the page to stay the same ie always demo.html with textarea and submit button and not the saving file content Any help is appretiated and as normal thank you in advance ... Hi, I'm trying to call a Js function from a test.js located in a HTML file. I'm getting error message "Object has no method..." in Chrome. But no issues are seen in Firefox. Can any one please let me know how i can fix this. <html> <head> .... .... .... <div> <html> <head> <script src="test.js"></script> <script> function aFunc() { alert ("Inside aFunc"); } </script> </head> <body> </html> .... .... .... </div> </head> </html> test.js function bFunc () { aFunc (); } 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> 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); Does anyone know how to accomplish this? I got the html file to show but none of the text in the file will show.
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 have the following sample html file (attached). I am trying to display the calculated field using javascript and I created a function (I am a newbie) to do so. However, it persistently shows NaN instead of the required number. I have tried my best over a coupla hours racking my brains and the internet as to why it shows as not a number. I will appreciate any help. Thanks, Freaking IE. Must die. Really it must. Unfortunately, I have to code for it, and I can't figure out what went wrong he http://wyqued-design.com/dev/skyview/index.html The navigation, and layout, breaks in IE 7. Any ideas? -Emilie Hello everyone. Below is code I have developed for a simple spreadsheet. The issue I am having is that when I total a row or column using "=sum(a1:a5)" and then I try and total another row and add the sum of the two totals together I am not getting a valid response back. All I am presented with is a "0" in the column cell. Here is the code in two files and have also included an attachment of the whole project: tablepage.js Code: // JavaScript Document var tblRows = 20; var tblColumns = 10; var tblArray = new Array(tblRows); var p = window.parent; // Initial page event handler function initPage() { p.refAssignCellFromTextbox = assignCellFromTextbox; for (var i = 0; i < tblArray.length; i++) { tblArray[i] = new Array(tblColumns); for (var j = 0; j < tblArray[i].length; j++) tblArray[i][j] = "0"; } recalculate(); } // Recalculate cell values function recalculate() { for (var i = 0; i < tblRows; i++) { for (var j = 0; j < tblColumns; j++) { if (tblArray[i][j].indexOf("=SUM") != -1) { calculateCell(i, j); } } } } // Click cell event handler function clickCell(cellRef) { thisRef = cellRef; var cellID = cellRef.id; var row = parseFloat(cellID.substr(0, 3)) - 1; var column = parseFloat(cellID.substr(3, 2)) - 1; var cellValue = tblArray[row][column]; var tokenArray = getFormula(cellValue); if (tokenArray != null) p.assignTextboxFromArray(cellValue); else p.assignTextboxFromCell(cellRef); } // Update cell from textbox function assignCellFromTextbox(tblValue) { if (thisRef != undefined) { if (tblValue == "") { tblValue = "0"; } var tokenArray = getFormula(tblValue); if (tokenArray != null) { assignArray(thisRef.id, tblValue.toUpperCase()); } else { if (!isFloat(tblValue)) { parseValue = tblValue.replace(/[^0-9]/g, ''); tblValue = parseValue; } assignArray(thisRef.id, tblValue); if (tblValue == "0") thisRef.innerText = ""; else thisRef.innerText = tblValue; } recalculate(); } } // Determines if a user entered a formula function getFormula(tblValue) { var pattern = /[:|\(|\)]/; var ar = tblValue.split(pattern); var sum = ar[0].toUpperCase(); if (ar.length < 3) return null; else if (sum != "=SUM") { return null; } else { return ar; } } function assignArray(cellID, tblValue) { var row = parseFloat(cellID.substr(0, 3)); var column = parseFloat(cellID.substr(3, 2)); tblArray[row - 1][column - 1] = tblValue; } function calculateCell(row, column) { var tokenArray = getFormula(tblArray[row][column]); if (tokenArray != null) { var fromColumn = tokenArray[1].substr(0, 1); var fromRow = tokenArray[1].substr(1, tokenArray[1].length - 1); var toColumn = tokenArray[2].substr(0, 1); var toRow = tokenArray[2].substr(1, tokenArray[2].length - 1); var fromRowIndex = parseFloat(fromRow) - 1; var fromColIndex = fromColumn.charCodeAt(0) - 65; var toRowIndex = parseFloat(toRow) - 1; var toColIndex = toColumn.charCodeAt(0) - 65; var sumTotal = 0; for (var i = fromRowIndex; i <= toRowIndex; i++) { for (var j = fromColIndex; j <= toColIndex; j++) { if (isFloat(tblArray[i][j])) sumTotal += parseFloat(tblArray[i][j]); } } var cellID = fillField((row + 1).toString(), 3) + fillField((column + 1).toString(), 2); document.getElementById(cellID).innerText = sumTotal; } } function isFloat(s) { var ch = ""; var justFloat = "0123456789."; for (var i = 0; i < s.length; i++) { ch = s.substr(i, 1); if (justFloat.indexOf(ch) == -1) return false; } return true; } function fillField(s,n) { var zeros = "0000000000"; return zeros.substring(0, n - s.length) + s; } spreadsheet.js Code: // JavaScript Document var refAssignCellFromTextbox; var nCharsAllowed = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.=(): "; // Event Handler function initPage() { document.getElementById("TableFrame").style.top = "50px"; document.getElementById("TableFrame").src = "tablepage.html"; } // Updates text field when a user clicks on a particular field from with the spreadsheet function assignTextboxFromCell(cValue) { document.getElementById("fieldEntry").value = cValue.innerText; document.getElementById("fieldEntry").focus(); } // Assists tablepage.js with updating a value from a 2D array function assignTextboxFromArray(aValue) { document.getElementById("fieldEntry").value = aValue; document.getElementById("fieldEntry").focus(); } // Used when a user presses a key to update text field function filterText() { if (window.event.keyCode != 13) { if (!nCharOK(window.event.keyCode)) window.event.keyCode = null; } else { window.event.keyCode = null; refAssignCellFromTextbox(document.getElementById("fieldEntry").value); } } // Checks to see if character entered falls within our preset function nCharOK(c) { var ch = (String.fromCharCode(c)); ch = ch.toUpperCase(); if (nCharsAllowed.indexOf(ch) != -1) return true; else return false; } // Clears all data from the screen function clearPage() { initPage(); document.getElementById("fieldEntry").value = ""; } // Add a row to the table function addRow(frmTable) { var table = document.getElementById(frmTable); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell1 = row.insertCell(0); // cell2.innerHTML = rowCount + 1; // Unless this is going to be completely dynamic // the rest of the table code would have had to be // entered in statically. Not happening. } // Delete a row from the table function deleteRow(frmTable) { try { var table = document.getElementById(frmTable); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; var chkbox = row.cells[0].childNodes[0]; if(null != chkbox && true == chkbox.checked) { table.deleteRow(i); rowCount--; i--; } } } catch(e) { alert(e); } } hi, i am trying to get some javascript working on a website i am making. the javascript changes the background image behind a photo. this simulates a user selecting a different frame from the drop down list http://jimpicot.com/shop/index.php?m...&products_id=3 below is the link to another forum it have been using to get most of the website working. http://www.zen-cart.com/forum/showthread.php?t=173765 For some reason I can not get this code to dump the information I type in into the mysql database...I'm sure I've missed something but can't seem to figure it out on my own. The mysql username & password are correct on my end & the fields match the mysql table column names. Do I have the code to connect & insert the fields into the mysql database in the correct place?? <?php # Page: add.php ########################## # Report all errors ########################## ini_set('display_errors',1); error_reporting(E_ALL); if( isset($_POST) && !empty($_POST) ) { # db connection settings ########################## # server IP $host = "localhost"; # sql user $user = "user"; # sql pw $pw = "mypassword"; # sql database $db = "psrflow"; # connect to db server ########################## $conn = mysql_connect( $host, $user, $pw ) or die( "Error! Unable to connect to database server: <br/>" . mysql_error() ); # connect to db ########################## $rs = mysql_select_db( $db, $conn ) or die( "Error! Unable to connect to database: <br/>" . mysql_error() ); # get submitted values & escape the text string foreach($_POST as $key=>$value) { ${$key}=mysql_real_escape_string($value); } $strSQL = "INSERT INTO psrinfo ( offender_fname, offender_lname, location, docket, officer, status, sent_date, assgn_date, interv_date, due_rev, due_suspo, due_clerk, due_attny, due_judge ) VALUES ( '" . $offender_fname . "', '" . $offender_lname . "', '" . $location . "', '" .$docket . "', '" .$officer ."', '" .$status ."', '".$sent_date ."', '".$assgn_date ."', '".$interv_date ."', '".$due_rev ."', '".$due_suspo ."', '".$due_clerk ."', '".$due_attny ."', '".$due_judge ."')"; # execute db insert ########################## if (!mysql_query( $strSQL, $conn )){ echo( "Unable to save data to database: <br/>" . mysql_error() . "<br/>" . $strSQL . "</span><br/>" ); } else{ header( "Location: index.html" ); exit; } } ?> <html> <head> <title>My Title</title> <script type="text/javascript"> var valid; function dcheck(form) { var a = form.assgn_date.value; var s = form.sent_date.value; var i = form.interv_date.value; var dr = form.due_rev.value var su = form.due_suspo var clk = form.due_clerk var att = form.due_attny var jdg = form.due_judge var assn = new Date(a); var sent = new Date(s); var intv = new Date(i); var due_rev = new Date(dr); var due_suspo = new Date(su); var due_clerk = new Date(clk); var due_attny = new Date(att); var due_judge = new Date(jdg); if (isNaN(assn)) { assn = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()+7); } if (isNaN(sent)) { sent = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()-7); } if (isNaN(intv)) { intv = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()+14); } if (isNaN(due_rev)) { due_rev = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()+15); } if (isNaN(due_suspo)) { due_suspo = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()+16); } if (isNaN(due_clerk)) { due_clerk = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()+17); } if (isNaN(due_attny)) { due_attny = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()+18); } if (isNaN(due_judge)) { due_judge = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()+19); } form.assgn_date.value = (assn.getMonth()+1) + "/" + assn.getDate() + "/" + assn.getFullYear(); form.sent_date.value = (sent.getMonth()+1) + "/" + sent.getDate() + "/" + sent.getFullYear(); form.interv_date.value = (intv.getMonth()+1) + "/" + intv.getDate() + "/" + intv.getFullYear(); form.due_rev.value = (due_rev.getMonth()+1) + "/" + due_rev.getDate() + "/" + due_rev.getFullYear(); form.due_suspo.value = (due_suspo.getMonth()+1) + "/" + due_suspo.getDate() + "/" + due_suspo.getFullYear(); form.due_clerk.value = (due_clerk.getMonth()+1) + "/" + due_clerk.getDate() + "/" + due_clerk.getFullYear(); form.due_attny.value = (due_attny.getMonth()+1) + "/" + due_attny.getDate() + "/" + due_attny.getFullYear(); form.due_judge.value = (due_judge.getMonth()+1) + "/" + due_judge.getDate() + "/" + due_judge.getFullYear(); return true; } </script> <style type="text/css"> body {background-color: #ffffff; margin-top: 60px;} </style> </head> <body> <form action="" method="get" onsubmit="return dcheck(this);"> <b>Docket No:</b> <br /> <input type="text" name="docket" size="30" /><br /> <b>First Name:</b> <br /> <input type="text" name="offender_fname" size="30" /><br /> <b>Last Name:</b> <br /> <input type="text" name="offender_lname" size="30" /><br /> <b>Status:</b> <br /> <input type="text" name="status" size="30" /><br /> <b>Location:</b> <br /> <input type="text" name="location" size="30" /><br /> <b>Officer:</b> <br /> <input type="text" name="officer" size="30" /><br /> <b>Sentence Date MM/DD/YYYY:</b /> <br /> <input type="text" size = "15" name="sent_date"> <br /> <b>Assign Date:</b>    <br /> <input type="text" size = "15" name="assgn_date"> <br /> <b>Invterview Date:</b>    <br /> <input type="text" size = "15" name="interv_date"> <br /> <b>Due to Reviewer:</b>    </br> <input type="text" size = "15" name="due_rev"> <br /> <b>Due to SUSPO:</b>    </br> <input type="text" size = "15" name="due_suspo"> <br /> <b>Due to Clerk:</b>    </br> <input type="text" size = "15" name="due_clerk"> <br /> <b>Due to Attorney:</b>    </br> <input type="text" size = "15" name="due_attny"> <br /> <b>Due to Judge:</b>    </br> <input type="text" size = "15" name="due_judge"> <br /> <br> <input type="button" value="Calculate" onclick="return dcheck(this.form);"> <input type="button" value="Reset" onclick="this.form.reset()"> <input type="submit" value="Submit" /> </form> </body> </html> Can someone help tell me where i've gone wrong! My finished script works in all browser except IE in IE it works on some machines not others, if i put the finesed page in a Iframe on another site it works but not in the original URL and on my machine it works if i go directly to the URL however if i hit refresh it doesn't work until i go directly to the URL again! In developer tools it comes up with the following error: SCRIPT5022: DOM Exception: TYPE_MISMATCH_ERR (17) cgl.js, line 147 character 3 here is the script it is referring too! Please help!!! PHP Code: var CGL = {}; CGL.canvas = { DEFAULT_CONTEXT : "2d", DEFAULT_CANVAS_ID : "cglcanvas", CANVAS_CONTAINER : "", CANVAS_WIDTH : 300, CANVAS_HEIGHT : 200, TARGET_FPS : 60, setDefault : function(option, value){ CGL.canvas[option] = value; }, getDefault : function(option){ return CGL.canvas[option]; }, /** * @method createCanvas(id, width, height) * @param id : sets the CANVAS_CONTAINER * @param width : sets the CANVAS_WIDTH * @param height : sets the CANVAS_HEIGHT * * Creates a <canvas> element that will be used as the main graphics container for the game! */ createCanvas : function(id, width, height){ var canvas = document.createElement("canvas"); CGL.canvas.CANVAS_WIDTH = width; CGL.canvas.CANVAS_HEIGHT = height; CGL.canvas.CANVAS_CONTAINER = id; canvas.setAttribute("width", width); canvas.setAttribute("height", height); canvas.style.borderColor = "black"; canvas.style.borderStyle = "solid"; canvas.style.borderWidth = "1px"; canvas.setAttribute("id", CGL.canvas.DEFAULT_CANVAS_ID); document.getElementById(id).appendChild(canvas); var elem = document.createElement("div"); elem.setAttribute("id", "status"); elem.style.width = width + "px"; elem.style.height = "120px"; elem.style.overflowY = "scroll"; elem.style.borderColor = "black"; elem.style.borderStyle = "solid"; elem.style.borderWidth = "1px"; elem.style.color = "black"; elem.style.backgroundColor = "white"; elem.style.display = "none"; document.getElementById(id).appendChild(elem); }, /** * @method getContext() * * Returns the graphic context as chosen by the DEFAULT_CONTEXT global. */ getContext : function(){ var canvas = document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID); return canvas.getContext(CGL.canvas.DEFAULT_CONTEXT); } }; CGL.image = { IMAGE_ID : 0, DEFAULT_IMAGECONT_ID : "imgcont", createImageContainer : function() { var div = document.createElement("div"); div.setAttribute("id", CGL.image.DEFAULT_IMAGECONT_ID); div.style.display = "none"; document.body.appendChild(div); }, load : function(src, id){ var img = document.createElement("img"); img.setAttribute("src", src); img.setAttribute("id", id); img.setAttribute("onload", "notifyLoaded(" + id + ")"); document.getElementById(CGL.image.DEFAULT_IMAGECONT_ID).appendChild(img); }, Image : function(source, uid, srcx, srcy){ var img = { id : uid, x : srcx, y : srcy }; CGL.image.load(source, uid); return img; }, render : function(ctx, img){ ctx.drawImage(document.getElementById(img.id), img.x, img.y); }, renderAt : function(ctx, imgid, x, y){ ctx.drawImage(document.getElementById(imgid), x, y); }, renderPart : function(ctx, imgid, srcx, srcy, srcwidth, srcheight, destx, desty, destwidth, destheight){ ctx.drawImage(document.getElementById(imgid), srcx, srcy, srcwidth, srcheight, destx, desty, destwidth, destheight); } }; CGL.sprite = { Sprite : function(frames, time){ var sprite = { active : true, speed : time || 500, activeFrame : 0, maxFrames : frames.length - 1, images : frames, timeCount : 0, loop : true, nextFrame : function(){ sprite.activeFrame += 1; if(sprite.activeFrame > sprite.maxFrames) { if(sprite.loop) { sprite.activeFrame = 0; } else { sprite.activeFrame = 0; sprite.active = false; } } }, setSpeed : function(time){ sprite.speed = time; }, setLoop : function(looping){ sprite.loop = looping; }, setActiveFrame : function(actFrame){ sprite.activeFrame = actFrame; }, stop : function(){ sprite.active = false; }, start : function(){ sprite.active = true; }, replay : function(){ sprite.activeFrame = 0; sprite.active = true; }, update : function(time){ if(sprite.active) { sprite.timeCount += time; } if(sprite.timeCount > sprite.speed) { sprite.nextFrame(); sprite.timeCount = 0; } }, render : function(ctx, x, y){ ctx.drawImage(document.getElementById(sprite.images[sprite.activeFrame]), x, y); } }; return sprite; } }; CGL.resource = { RESOURCES : 0, loadImages : function(xml){ var image, elem, i; var img = new Array(); var imgsrc, imgid; xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ image = xmlhttp.responseXML.documentElement.getElementsByTagName("image"); for(i = 0; i < image.length; i++){ elem = image[i].getElementsByTagName("src"); try{ imgsrc = elem[0].firstChild.nodeValue; } catch(er){ } elem = image[i].getElementsByTagName("id"); try{ imgid = elem[0].firstChild.nodeValue; } catch(er){ } CGL.image.load(imgsrc, imgid); img[i] = imgid; CGL.resource.RESOURCES++; CGL.util.printLn("Loaded Image: " + imgsrc + " With ID: " + imgid); } } }; xmlhttp.open("GET",xml,false); xmlhttp.send(); return img; } }; CGL.highscore = { highscore : function(url, posts) { var highScore = { name : new Array(posts), score : new Array(posts), level : new Array(posts), size : posts, getHighScore : function() { highScore.size = 10; xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var string = xmlhttp.responseText; var list = eval( "(" + string + ")" ); for(i = 0; i < list.length; i++){ highScore.name[i] = list[i].name; highScore.score[i] = list[i].score; highScore.level[i] = list[i].level; } highScore.size = list.length; } } xmlhttp.open("GET",url + "?action=get&posts=" + highScore.size ,false); xmlhttp.send(); }, recordHighScore : function(name, level, score) { xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { CGL.util.printLn(xmlhttp.responseText); } } xmlhttp.open("GET",url + "?action=put&name=" + name + "&score=" + score + "&level=" + level ,false); xmlhttp.send(); }, reInit : function() { for(var i = 0; i < highScore.size; i++) { delete highScore.name[highScore.size-i]; delete highScore.score[highScore.size-i]; delete highScore.level[highScore.size-i]; } } }; return highScore; } }; CGL.ajax = { _createXHR : function() { try { return new XMLHttpRequest(); } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) {} try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} return null; } }; CGL.util = { MESSAGE_ID : 0, LASTUPDATE : 0, UPDATE_RPS : 40, printLn : function(message) { var elem = document.createElement("p"); elem.setAttribute("id", CGL.util.MESSAGE_ID); document.getElementById("status").appendChild(elem); document.getElementById(CGL.util.MESSAGE_ID).innerHTML = CGL.util.MESSAGE_ID + " : " + message; CGL.util.MESSAGE_ID++; }, gameTimer : function() { delta = new Date(); if(delta.getTime() > CGL.util.LASTUPDATE + 1000/CGL.util.UPDATE_RPS) { CGL.util.LASTUPDATE = delta.getTime(); return true; } else return false; }, }; CGL.math = { Vector2 : function(vx, vy) { var Vector2 = { x : vx || 0.0, y : vy || 0.0, interpolate : function(a_vec, b_vec, a_f){ return a_vec.mul(a_f).add(b_vec.mul(1-a_f)); }, mul : function(other){ Vector2.x *= other.x; Vector2.y *= other.y; }, mulScale : function(scale) { Vector2.x *= scale; Vector2.y *= scale; }, sub : function(other) { Vector2.x -= other.x; Vector2.y -= other.y; }, add : function(other) { Vector2.x += other.x; Vector2.y += other.y; }, div : function(other) { Vector2.x /= other.x; Vector2.y /= other.x; }, divScale : function(scale) { Vector2.x /= scale; Vector2.y /= scale; }, scale : function(a_f, a_g){ return new CGL.math.Vector2d(a_f * Vector2d.m_x, a_g * Vector2d.m_y); }, dot : function(other) { return ((Vector2.x * other.x) + (Vector2.y * other.y)); }, neg : function() { return new CGL.math.Vector2(-Vector2.x, -Vector2.y); }, normalize : function() { var l = Vector2.length(); if(l == 0){ return; } Vector2.x /= l; Vector2.y /= l; }, lengthSquared : function() { return (Vector2.x * Vector2.x) + (Vector2.y * Vector2.y); }, length : function() { return Math.sqrt(Vector2.lengthSquared()); }, toString : function() { return "[Vector (" + Vector2.x + ", " + Vector2.y + ")]"; }, copy : function(other) { Vector2.x = other.x; Vector2.y = other.y; }, draw : function(ctx) { /* Convert to Local space */ var lx, ly; if(Vector2.x < 0.0) { lx = (-Vector2.x * -50) + 200; } else { lx = (Vector2.x * 50) + 200; } if(Vector2.y > 0.0) { ly = (Vector2.y * -50) + 200; } else { ly = (-Vector2.y * 50) + 200; } ctx.beginPath(); ctx.arc(lx, ly, 2, 0, Math.PI*2, true); // Outer circle ctx.fill(); } }; return Vector2; }, getNormal : function(vx, vy) { var n = new CGL.math.Vector2(vy.x, vy.y); n.sub(vx); n = new CGL.math.Vector2(n.y, -n.x); n.normalize(); return n; } }; CGL.ui = { Button : function(imgs, srcx, srcy, srcwidth, srcheight) { var button = { images : imgs, x : srcx, y : srcy, width : srcwidth, height : srcheight, active : false, clicked : false, update : function(mx, my, mb) { if(mx > button.x && mx < button.x + button.width && my > button.y && my < button.y + button.height) { button.active = true; } else { button.active = false; } if(button.active && mb) { button.clicked = true; } }, activated : function() { return button.clicked; }, deactivate : function() { button.clicked = false; }, render : function(ctx) { if(!button.active) { ctx.drawImage(document.getElementById(button.images[0]), button.x, button.y); } else { ctx.drawImage(document.getElementById(button.images[1]), button.x, button.y); } } }; return button; } }; CGL.event = { MOUSEX : 0, MOUSEY : 0, KLEFT : false, KRIGHT : false, KDOWN : false, KUP : false, KSPACE : false, KPAUSE : false, CLICKED : false, ACTIVEGAMEKEY : true, handleEventMovement : function(e) { CGL.event.getCursorPosition(e); }, handleEventClick : function(e) { CGL.event.CLICKED = true; }, clearEvents : function() { CGL.event.KLEFT = false; CGL.event.KRIGHT = false; CGL.event.KDOWN = false; CGL.event.KUP = false; CGL.event.KSPACE = false; CGL.event.KPAUSE = false; CGL.event.CLICKED = false; }, handleEventKey : function(e) { if(CGL.event.ACTIVEGAMEKEY) { e.stopPropagation(); e.preventDefault(); } switch(e.keyCode) { case 19: CGL.event.KPAUSE = true; break; case 32: CGL.event.SPACE = true; CGL.util.printLn("Space was triggered!"); break; case 37: CGL.event.KLEFT = true; break; case 38: CGL.event.KUP = true; break; case 39: CGL.event.KRIGHT = true; break; case 40: CGL.event.KDOWN = true; break; case 65: CGL.event.KLEFT = true; CGL.util.printLn("Left was triggered!"); break; case 87: CGL.event.KUP = true; CGL.util.printLn("Up was triggered!"); break; case 68: CGL.event.KRIGHT = true; CGL.util.printLn("Right was triggered!"); break; case 80: CGL.event.KPAUSE = true; break; case 83: CGL.event.KDOWN = true; CGL.util.printLn("Down was triggered!"); break; default: break; }; }, getCursorPosition : function(e) { if (e.pageX != undefined && e.pageY != undefined) { CGL.event.MOUSEX = e.pageX; CGL.event.MOUSEY = e.pageY; } else { CGL.event.MOUSEX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; CGL.event.MOUSEY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } CGL.event.MOUSEX -= document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID).offsetLeft; CGL.event.MOUSEY -= document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID).offsetTop; } }; Hi all, I have a problem where I'm trying to load data into multiple divs. They are payslips, so p1, goes into january, p2 into febuary etc. I want to onLoad them all so when the page is loaded they are all displayed. Every time I try this, the loop automatically goes to the last iteration, 6 in this example, so the only div that is loaded is p6. Here is my code: function replace(slip, year) { // table contains either 'bank' or 'intranet' xmlHttpReq.open("POST", "do_payslips_ajax.php", true); xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttpReq.onreadystatechange=function() { if(xmlHttpReq.readyState == 4) { document.getElementById("p" + slip).innerHTML = xmlHttpReq.responseText; } } xmlHttpReq.send(getquery(slip,year)); } function getquery(slip,year) { strQuery = "weekmonth=" + slip + "." + year; return strQuery; } function loadpayslips(year) { for (slip=1; slip<=6; slip++) { replace(slip, year); } } <label> <body onload = loadpayslips(11)> search</a> </label> <div id="p1"> /div> <div id="p2"> month 2</div> <div id="p3"> month 5</div> etc.. Any help would be appreciated. Thanks |