JavaScript - Is This Code Efficient?
Right.. I'm still new to javascript so i've just been messing about with some code and came up with a pointless small program i just wanted to know if the code written is efficient? in other words are there other ways that would be more suitable or are certain parts of the code wrong?
The script basically does this. 1. prompts you to enter a time interval in the range of 1 second to 10 seconds 2. A small box appears with a random number generated at the time interval the user entered. IF you enter a number lower or higher then in that range it prompts you again to enter a valid number. If you click cancel you automatically get a time interval of 1 second Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>JavaScript</title> <style type="text/css"> #textbox1{border:1px solid #999;} #fieldsetid{width:157px; border:1px solid #777; font-family:Verdana; margin: 0 auto 0 auto;} </style> <script type="text/javascript"> var count = 0; //Time interval in seconds. do { var getNewValue = prompt("please enter in seconds the interval time", secondTime); var count = getNewValue; if(getNewValue == null){ var count = 1; } if(count > 10){ var secondTime = "please enter a number from 1 to 10"; } } while(count < 1 || count > 10); function makeNumNow() { var MakeNum = Math.random() * 12345678901234567; var result = Math.round(MakeNum); document.form1.textbox1.value = result; } setInterval("makeNumNow()", count*1000); </script> </head> <body> <script type="text/javascript"> </script> <fieldset id="fieldsetid"> <legend>Random Number</legend> <form name="form1"> <input id="textbox1" type="text" name="textbox" value="" /> </form> </fieldset> </body> </html> Similar TutorialsRight now I am using the following method to show/hide divs containing videos. html Code: <div class="vidPop" id="vidPop"> <div class="vidFrame" id="vidFrame"> <iframe id="Iframe1" src="http://player.vimeo.com/video/xxxxxxx1" width="640" height="360" frameborder="0"></iframe> <div class="vidClose"><a href="#" onclick="vidPopdown()"><img src="images/closeban.png" width="52" height="52" alt="close" /></a></div> </div> </div> <div class="vidPop2" id="vidPop2"> <div class="vidFrame2" id="vidFrame2"> <iframe id="Iframe2" src="http://player.vimeo.com/video/xxxxxxx2" width="640" height="360" frameborder="0"></iframe> <div class="vidClose"><a href="#" onclick="vidPopdown2()"><img src="images/closeban.png" width="52" height="52" alt="close" /></a></div> </div> </div> js Code: function vidPopup() { var o = document.getElementById('vidPop'); o.style.visibility = 'visible'; o = document.getElementById('vidFrame'); o.style.visibility = 'visible'; } function vidPopdown() { var o = document.getElementById('vidPop'); o.style.visibility = 'hidden'; o = document.getElementById('vidFrame'); o.style.visibility = 'hidden'; document.getElementById('Iframe1').src = document.getElementById('Iframe1').src } function vidPopup2() { var o = document.getElementById('vidPop2'); o.style.visibility = 'visible'; o = document.getElementById('vidFrame2'); o.style.visibility = 'visible'; } function vidPopdown2() { var o = document.getElementById('vidPop2'); o.style.visibility = 'hidden'; o = document.getElementById('vidFrame2'); o.style.visibility = 'hidden'; document.getElementById('Iframe2').src = document.getElementById('Iframe2').src } all of this works just fine, but now I am adding yet another video, and I know that this isn't the best way to go about doing this. I ought to be able to use 1 function and tell it which iframe to load, however I dont really know javascript. Any and all help on this would be greatly appreciated. What is the most efficient type of chat to make? From what I see online most people use a database and limit the number of results they return, but I noticed that some chats, like google and facebook, for some reason are able to load the full chat and get results almost instantly. How do they do it? I would love to make a replica of a google chat and just redesign the way it looks. If anyone can help me with the javascript/php part of this, that would be great. thanks! So I made myself this code so I could have a file upload input field, and the option to add more fields. but it got really big, and I have a fixed number of fields, can't quickly change the number I want. here's my javascript: Code: function new_field(id) { var f = document.getElementById(id); if(f.style.display == 'none') f.style.display = 'block'; } function hide_mais(id) { var g = document.getElementById(id); g.style.display = 'none'; } and the html: Code: <form> <div id="file_a" style="display:block"><input type="file" /><a href="#" id="link_a" onclick="new_field('file_b');hide_mais('link_a')">mais</a></div> <div id="file_b" style="display:none"><input type="file" /><a href="#" id="link_b" onclick="new_field('file_c');hide_mais('link_b')">mais</a></div> <div id="file_c" style="display:none"><input type="file" /><a href="#" id="link_c" onclick="new_field('file_d');hide_mais('link_c')">mais</a></div> <div id="file_d" style="display:none"><input type="file" /><a href="#" id="link_d" onclick="new_field('file_e');hide_mais('link_d')">mais</a></div> <div id="file_e" style="display:none"><input type="file" /><a href="#" id="link_e" onclick="new_field('file_f');hide_mais('link_e')">mais</a></div> <div id="file_f" style="display:none"><input type="file" /><a href="#" id="link_f" onclick="new_field('file_g');hide_mais('link_f')">mais</a></div> <div id="file_g" style="display:none"><input type="file" /><a href="#" id="link_g" onclick="new_field('file_h');hide_mais('link_g')">mais</a></div> <div id="file_h" style="display:none"><input type="file" /><a href="#" id="link_h" onclick="new_field('file_i');hide_mais('link_h')">mais</a></div> <div id="file_i" style="display:none"><input type="file" /><a href="#" id="link_i" onclick="new_field('file_j');hide_mais('link_i')">mais</a></div> <div id="file_j" style="display:none"><input type="file" /><a href="#" id="link_j" onclick="new_field('file_k');hide_mais('link_j')">mais</a></div> <div id="file_k" style="display:none"><input type="file" /><a href="#" id="link_k" onclick="new_field('file_l');hide_mais('link_k')">mais</a></div> <div id="file_l" style="display:none"><input type="file" /><a href="#" id="link_l" onclick="new_field('file_m');hide_mais('link_l')">mais</a></div> <div id="file_m" style="display:none"><input type="file" /><a href="#" id="link_m" onclick="new_field('file_n');hide_mais('link_m')">mais</a></div> <div id="file_n" style="display:none"><input type="file" /><a href="#" id="link_n" onclick="new_field('file_o');hide_mais('link_n')">mais</a></div> <div id="file_o" style="display:none"><input type="file" /><a href="#" id="link_o" onclick="new_field('file_p');hide_mais('link_o')">mais</a></div> <div id="file_p" style="display:none"><input type="file" /><a href="#" id="link_p" onclick="new_field('file_q');hide_mais('link_p')">mais</a></div> <div id="file_q" style="display:none"><input type="file" /><a href="#" id="link_q" onclick="new_field('file_r');hide_mais('link_q')">mais</a></div> <div id="file_r" style="display:none"><input type="file" /><a href="#" id="link_r" onclick="new_field('file_s');hide_mais('link_r')">mais</a></div> <div id="file_s" style="display:none"><input type="file" /><a href="#" id="link_s" onclick="new_field('file_t');hide_mais('link_s')">mais</a></div> <div id="file_t" style="display:none"><input type="file" /><a href="#" id="link_t" onclick="new_field('file_u');hide_mais('link_t')">mais</a></div> <div id="file_u" style="display:none"><input type="file" /><a href="#" id="link_u" onclick="new_field('file_v');hide_mais('link_u')">mais</a></div> <div id="file_v" style="display:none"><input type="file" /><a href="#" id="link_v" onclick="new_field('file_w');hide_mais('link_v')">mais</a></div> <div id="file_w" style="display:none"><input type="file" /><a href="#" id="link_w" onclick="new_field('file_x');hide_mais('link_w')">mais</a></div> <div id="file_x" style="display:none"><input type="file" /><a href="#" id="link_x" onclick="new_field('file_y');hide_mais('link_x')">mais</a></div> <div id="file_y" style="display:none"><input type="file" /><a href="#" id="link_y" onclick="new_field('file_z');hide_mais('link_y')">mais</a></div> <div id="file_z" style="display:none"></div> </form> any suggestions of a more efficient way to do that? also a button to reset form into initial state, with one field only, without having to refresh the page would be cool. thanks in advance If you go to a Youtube video by Justin Bieber or Rebecca Black, comments are constantly being posted and it seems like the autorefresh for the comments kicks in every half second. I don't plan on having millions of users viewing my page, but still, wouldn't having every user make a [mysql] request to the server every half second really take a toll on the server (especially since I don't plan to ever have the resources that Youtube has)? Facebook also seems to have instantaneous auto-refreshes, be it in comment boxes or their chat interface. So what would be the best method to implement a near-instantaneous autorefresh system with minimal resource usage? Hi all, I've been trying to build a form with dynamic checkboxes. I'd like to have a master 'select none' checkbox in a few form fields which has 2 key functions:- 1) clearing all field boxes the user may have entered before opting to select none 2) disabling all field options to make it impossible for the user to tick both 'none' and other options. This 'select none' checkbox should be ticked by default, so when the user unchecks it, the rest of the field options light up. I'm a complete novice but I have it working ok having stitched a few pieces of code I've found together, however I don't think it's very efficient. I have had to duplicate both bits of the javascript to make it work, changing only the function names in the <head> area ('Uncheck' and 'Uncheck2') and the class variables in the form in the <body> area ('fruit_child' and 'veg_child'). As this form will have several more fields eventually, I'm looking for a better way to do this while maintaining the functionality. Ive read bits about object-orientated programming which may be what I'm looking for to make this more efficient, but I'm not sure how to implement it in this example. Can a more experienced coder please help? Kind thanks, Fleef Code: <head> <SCRIPT LANGUAGE="JavaScript"> // Check_ctr: clears all when 'none' box ticked --> function Uncheck(chk) { if(document.myform.Check_ctr.checked==true){ for (i = 0; i < chk.length; i++) chk[i].checked = false ; } } // End --> </script> <SCRIPT LANGUAGE="JavaScript"> // Check_ctr: clears all when 'none' box ticked --> function Uncheck2(chk_veg) { if(document.myform.Check_ctr_veg.checked==true){ for (i = 0; i < chk_veg.length; i++) chk_veg[i].checked = false ; } } // End --> </script> </head> <body> <form name="myform" method="post"> <input type="checkbox" id="none_fruit" name="Check_ctr" value="yes" onClick="Uncheck(document.myform.fruit)" checked><b>None</b><br> <input type="checkbox" name="fruit" value="1" class="fruit_child" disabled="true">1<br> <input type="checkbox" name="fruit" value="2" class="fruit_child" disabled="true">2<br> <input type="checkbox" name="fruit" value="3" class="fruit_child" disabled="true">3<br> <input type="checkbox" name="fruit" value="4" class="fruit_child" disabled="true">4<br> <input type="checkbox" name="fruit" value="5" class="fruit_child" disabled="true">5<br> <script> // disables options when 'none' ticked --> $(function(){ $("#none_fruit").click ( function() { if ( !$(this).is ( ":checked" ) ) { $(".fruit_child").removeAttr ( "disabled" ); } else { $(".fruit_child").attr ( "disabled" , true ); } }); });</script> <br><br><br> <input type="checkbox" id="none_veg" name="Check_ctr_veg" value="yes" onClick="Uncheck2(document.myform.veg)" checked><b>None</b><br> <input type="checkbox" name="veg" value="1" class="veg_child" disabled="true">1<br> <input type="checkbox" name="veg" value="2" class="veg_child" disabled="true">2<br> <input type="checkbox" name="veg" value="3" class="veg_child" disabled="true">3<br> <input type="checkbox" name="veg" value="4" class="veg_child" disabled="true">4<br> <input type="checkbox" name="veg" value="5" class="veg_child" disabled="true">5<br> <script> // disables options when 'none' ticked --> $(function(){ $("#none_veg").click ( function() { if ( !$(this).is ( ":checked" ) ) { $(".veg_child").removeAttr ( "disabled" ); } else { $(".veg_child").attr ( "disabled" , true ); } }); });</script> </form> This post will contain a few guidelines for what you can do to get better help from us. Let's start with the obvious ones: - Use regular language. A spelling mistake or two isn't anything I'd complain about, but 1337-speak, all-lower-case-with-no-punctuation or huge amounts of run-in text in a single paragraph doesn't make it easier for us to help you. - Be verbose. We can't look in our crystal bowl and see the problem you have, so describe it in as much detail as possible. - Cut-and-paste the problem code. Don't retype it into the post, do a cut-and-paste of the actual production code. It's hard to debug code if we can't see it, and this way you make sure any spelling errors or such are caught and no new ones are introduced. - Post code within code tags, like this [code]your code here[/code]. This will display like so: Code: alert("This is some JavaScript code!") - Please, post the relevant code. If the code is large and complex, give us a link so we can see it in action, and just post snippets of it on the boards. - If the code is on an intranet or otherwise is not openly accessible, put it somewhere where we can access it. - Tell us any error messages from the JavaScript console in Firefox or Opera. (If you haven't tested it in those browsers, please do!) - If the code has both HTML/XML and JavaScript components, please show us both and not just part of it. - If the code has frames, iframes, objects, embeds, popups, XMLHttpRequest or similar components, tell us if you are trying it locally or from a server, and if the code is on the same or different servers. - We don't want to see the server side code in the form of PHP, PERL, ASP, JSP, ColdFusion or any other server side format. Show us the same code you send the browser. That is, show us the generated code, after the server has done it's thing. Generally, this is the code you see on a view-source in the browser, and specifically NOT the .php or .asp (or whatever) source code. I'm trying to get my Client Side Firefox DHTML app to display a list of eBooks. For this, i have the following files F:\Textbooks.html F:\eBooks.txt F:\FirstBook.txt F:\SecondBook.txt F:\ThirdBook.txt textbooks.html is my DHTML app eBooks.txt is the Library file with a listing of all of my eBooks. Inside of eBooks.txt is the following data: ----------------- FirstBook.txt, SecondBook.txt, ThirdBook.txt, ----------------- FirstBook.txt to ThirdBook.txt are my actual ebooks. The problem that i'm having is that When i try to click on any buttons other than the FirstBook button, i get the following error: ---------------------------------- Error: unterminated string literal Source File: file:///F:/Textbooks.html Line: 1, Column: 10 Source Code: LoadEbook(' ---------------------------------- So, unlike clicking on the FirstBook button, these other buttons do not load the eBook data into the DIV for displaying the eBook data. I use the DOM insepector to checkout the DOM of the button code, and it seems like whitespace maybe is the problem. However, i have removed whitespace from the HTMLdata string, and that's not fixing the problem. did i forget something silly? LOL i'm using FireFox 3.5 to develop this App. So obviously this will not work with anything other than Gecko Based browsers. here is my HTML code: <html> <head> <script language="JavaScript"> var eBookLibrary = "eBooks.txt"; var SystemPath = "f:" + String.fromCharCode(92) function Init() { // Initialize the eBook reader document.getElementById("EbookCanvas").style.visibility = "hidden"; document.getElementById("EbookToolbar").style.visibility = "visible"; document.getElementById("FileManager").style.visibility = "visible"; // Load the List of eBooks in the Library LoadBookList(); } function UpdateEbookList() { // Update the Library of Ebooks alert("Updating eBook Library"); // Go back to the File Manager, and Reload the List of Ebooks LoadBookList(); } function LoadBookList() { // This will load the list of books that are available var EbookList = LoadFromDisk(SystemPath + eBookLibrary); var EbookListArray = EbookList.split(","); for(var x = 0; x < EbookListArray.length -1; x++) { // Strip the Filename Extension off of the eBook File Name // The Name of the Book is always the first Index in the Array var BookName = EbookListArray[x].split("."); // Remove the weird whitespace - it screws things up...i think... BookName[0] = BookName[0].replace(/(^\s*|\s*$)/g, ""); var HTMLdata = HTMLdata + "<input type='button' value='" + "FirstBook" + "'" + " onClick=LoadEbook('" + EbookListArray[x] + "');><br>"; } // For some ****ed up reason the first string always generates an 'undefined' even though it's nonsense // So just delete that from the HTMLdata string, because it's just ugly - LOL HTMLdata = HTMLdata.replace("undefined", ""); HTMLdata = HTMLdata.replace("", " "); // Write the HTML data to the DIV document.getElementById("FileManager").innerHTML = HTMLdata; } function LoadEbook(EbookName) { // Hide the File Manager and Show the Ebook Canvas document.getElementById("FileManager").style.visibility = "hidden"; document.getElementById("EbookCanvas").style.visibility = "visible"; document.getElementById("EbookToolbar").style.visibility = "visible"; // Load the Ebook content into the Ebook Reader Pannel var EbookContent = LoadFromDisk(SystemPath + EbookName); document.getElementById("EbookCanvas").innerHTML = EbookContent; } function LoadFromDisk(filePath) { if(window.Components) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if (!file.exists()) return(null); var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); inputStream.init(file, 0x01, 00004, null); var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); sInputStream.init(inputStream); return(sInputStream.read(sInputStream.available())); } catch(e) { //alert("Exception while attempting to load\n\n" + e); return(false); } return(null); } </script> </head> <body onLoad="Init();"> <div id="FileManager" style="position: absolute; top: 0px; left: 0px; visibility: visible;"> The eBook Library's List of Books will be listed here. Click on one to open it in the eBook Reader </div> <br> <div id="EbookCanvas" style="position: absolute; top: 0px; left: 0px; visibility: hidden;"> </div> <br> <div id="EbookToolbar" style="position: absolute; top: 100px; left: 0px;"> <input type="button" value="Open" OnClick="Init();"> <input type="button" value="Update" OnClick="UpdateEbookList();"> <input type="button" value="Exit" OnClick="MainMenu();"> </div> </body> </html> Hi all, I hope someone can advise whether such a script exists for what am wanting to do. From time to time, I need to send password information or login details and password information to some users. At the moment, am doing it via email with a subject named FYI and the body of the email basically just contain the login and the password or in some case, just the password. What am wanting to know is whether I can put these information into a HTML file which contains an obfuscated Javascript with a button that a user will click that will prompt for his login information and then will display the password. In its simplest form, I guess I am looking for a Javascript that will obfuscate a HTML file that contains the password. Anyway, hopefully someone understand what am looking for. I found some website that offers such service as obfuscating a HTML file but am hoping it can be done via a Javascript so it is at least "portable" and I do not have to be online. Any advice will be much appreciated. Thanks in advance. Hi guys.. I really need a bit of help.. is anyone looking at this good with JS? I have a php form validation script but i think its a bit slow and would rather a JS script instead... here is what i have in php.. PHP Code: <?php if(isset($_POST['submit'])) { $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $email = $_POST['email']; $mobile = $_POST['mobile']; $comments = $_POST['comments']; $errors = array(); function display_errors($error) { echo "<p class=\"formMessage\">"; echo $error[0]; echo "</p>"; } function validateNames($names) { return(strlen($names) < 3); } function validateEmail($strValue) { $strPattern = '/([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})/sim'; return(preg_match($strPattern,$strValue)); } function validateMobile($strValue) { $strPattern = '/^\d{10}$/'; return(preg_match($strPattern,$strValue)); } function validateComments($comments) { return(strlen($comments) < 10); } if(validateNames($firstName)) { $errors[] = 'Please Enter Your First Name'; } if(validateNames($lastName)) { $errors[] = 'Please Enter Your Second Name'; } if(!validateEmail($email)) { $errors[] = 'Please Enter Your Correct Email'; } if(!validateMobile($mobile)) { $errors[] = 'Please Enter Your Correct Mobile Number'; } if(validateComments($comments)) { $errors[] = 'Please Enter A Comment More Than 10 Characters'; } if(empty($errors)) { $to = "info@eventpromotion.ie"; $subject = "Event Promotion Enquiry!"; $body = "First Name: " . $_POST['firstName'] . "\nLast Name: " . $_POST['lastName'] . "\nEmail: " . $_POST['email'] . "\nMobile: " . $_POST['mobile'] . "\nMessage: " . $_POST['comments']; $headers = "From: ". $firstName ." ". $lastName . " <" . $email . ">\r\n"; if (mail($to, $subject, $body, $headers)) { echo("<p class=\"formMessage\">Thanks for submitting your enquiry.</p>"); } else { echo("<p class=\"formMessage\">Message delivery failed.</p>"); } } else { //echo "error"; display_errors($errors); } } ?> <form id="form" method="post" action="index.php#quickContact"> <p> <label>First Name</label><br /> <input type="text" name="firstName" value="<?php if(isset($firstName)){echo $firstName;} ?>" /> </p> <p> <label>Last Name</label><br /> <input type="text" name="lastName" value="<?php if(isset($lastName)){echo $lastName;} ?>" /> </p> <p> <label>Email:</label><br /> <input type="text" name="email" value="<?php if(isset($email)){echo $email;} ?>" /> </p> <p> <label>Mobile:</label><br /> <input type="text" name="mobile" value="<?php if(isset($mobile)){echo $mobile;} ?>" /> </p> <p> <label>Comments:</label> <br /> <textarea name="comments" cols="30" rows="3" ><?php if(isset($comments)){echo $comments;} ?></textarea> </p> <p> <input class="send" type="image" src="images/submit2.gif" name="submit" value="Submit" /></p> </form> does anyone know how to transfer this to JS so that it will be easy to understand.. Im not good with JS at all I am trying to set up a looping structure that tests to see if the user enters a value. If the textbox is null then a global variable is false otherwise a checkbox is checked and the global variable is true. below is what i have done so far, please assist me. var isValid = false; window.onload = startForm; function startForm() { document.forms[0].firstName.focus(); document.forms[0].onsubmit = checkEntries; alert("You have been added to the list") } function checkEntries() { var menus = new Array(); var formObject = document.getElementsByTagName('*'); for (var i=0; i < formObject.length; i++){ if (formObject[i] == "myform") menus.push(formObject[i]); if (document.forms[0].firstName.value.length==0 || document.forms[0].firstName.value.length == null){ isValid= false; alert("Please enter a first name"); } else (document.forms[0].check0.checked=true); isValid=true; if (document.forms[0].lastName=="" || document.forms[0].lastName== null){ alert("Please enter a last name"); isValid = false; } else (document.forms[0].check1.checked=true); isValid=true; if (document.forms[0].email=="" || document.forms[0].email== null) { alert("Please enter a valid email"); } else return (document.forms[0].check0.checked=true); isValid=true; if (document.forms[0].bDate=="" || document.forms[0].bDate== null) { isValid=false; alert("please make sure you enter a valid birth date."); } else (document.forms[0].check0.checked=true); isValid=true; } } here is the form html... <form name="myform" > <input type="checkbox" name="check0" class="check0" id="check0" > First: <input type="text" name="firstName" id="firstName"> <BR> <input type="checkbox" name="check1" class="check1" id="check1" > Last: <input type="text" name="lastName" id="lastName" ><BR> <input type="checkbox" name="check2" class="check2" id="check2" > E-Mail: <input type="text" name="email" id="email"> <BR> <input type="checkbox" name="check3" class="check3" id="check3" > Birthday (mm/dd/yyyy): <input type="text" name="bDate" id="bDate"> <BR> <input type="submit" value="Join our mailing List" /> </form> 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> Ok guys if you look at this page www.runningprofiles.com/members/shout/view.php my code works great.... But when i add it to the rest of the script the code wont work shows he http://www.runningprofiles.com/membe...ll_Script.php# Below is view.php (the one that works) and the one added to the code scirpt is the one the does not. PHP Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript"> $(function() { $(".view_comments").click(function() { var ID = $(this).attr("id"); $.ajax({ type: "POST", url: "viewajax.php", data: "msg_id="+ ID, cache: false, success: function(html){ $("#view_comments"+ID).prepend(html); $("#view"+ID).remove(); $("#two_comments"+ID).remove(); } }); return false; }); }); </script> <ol> <?php //Here $id is main message msg_id value. $csql=mysql_query("select * from comments where msg_id_fk='130' order by com_id "); $comment_count=mysql_num_rows($csql); if($comment_count>2) { $second_count=$comment_count-2; ?> <div class="comment_ui" id="view130"> <a href="#" class="view_comments" id="130">View all <?php echo $comment_count; ?> comments</a> </div> <?php } else { $second_count=0; } ?> <div id="view_comments130"></div> <div id="two_comments130"> <table width="30%"> <?php $small=mysql_query("select * from comments where msg_id_fk='130' order by com_id limit $second_count,2 "); while($rowsmall=mysql_fetch_array($small)) { $c_id=$rowsmall['com_id']; $comment=$rowsmall['comment']; ?> <div class="comment_actual_text"> <tr> <td style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid" valign="top"> <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse" align="left"> <tr> <td width="5%" style="VERTICAL-ALIGN: middle; TEXT-ALIGN: center"><img style="WIDTH: 30px; HEIGHT: 30px" alt="srinivas" src="http://www.gravatar.com/avatar.php?gravatar_id=7a9e87053519e0e7a21bb69d1deb6dfe" border="1" /></td> <td style="VERTICAL-ALIGN: top; TEXT-ALIGN: left"> <strong>Jarratt</strong> <?php echo $comment; ?> <br /><span style="COLOR: #a9a9a9">10 min ago - ID = <?php echo $c_id;?> </span></td> </tr> </table><br /> </td> </tr> </div> <?php } ?> </table> </div> </ol> Facebook_Wall_Script.php PHP 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=iso-8859-1" /> <title>9lessons Applicatio Demo</title> <link href="frame.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript" src="jquery.oembed.js"></script> <script type="text/javascript"> <script type="text/javascript"> $(function() { $(".view_comments").click(function() { var ID = $(this).attr("id"); $.ajax({ type: "POST", url: "../viewajax.php", data: "msg_id="+ ID, cache: false, success: function(html){ $("#view_comments"+ID).prepend(html); $("#view"+ID).remove(); $("#two_comments"+ID).remove(); } }); return false; }); }); $(function() { $(".comment_button").click(function() { var element = $(this); var boxval = $("#content").val(); var dataString = 'content='+ boxval; if(boxval=='') { alert("Please Enter Some Text"); } else { $("#flash").show(); $("#flash").fadeIn(400).html('<img src="ajax.gif" align="absmiddle"> <span class="loading">Loading Update...</span>'); $.ajax({ type: "POST", url: "update_ajax.php", data: dataString, cache: false, success: function(html){ $("ol#update").prepend(html); $("ol#update li:first").slideDown("slow"); document.getElementById('content').value=''; $('#content').value=''; $('#content').focus(); $("#flash").hide(); $("#expand_url").oembed(boxval); } }); } return false; }); / Delete Wall Update $('.delete_update').live("click",function() { var ID = $(this).attr("id"); var dataString = 'msg_id='+ ID; var parent=$("#bar"+ID); jConfirm('Are you sure you want to delete this message?', 'Confirmation Dialog', function(r) { if(r==true) { $.ajax({ type: "POST", url: "delete_update.php", data: dataString, cache: false, success: function(html){ parent.slideUp(300,function() { parent.remove(); }); } }); } }); return false; });//comment slide $('.comment').live("click",function() { var ID = $(this).attr("id"); $(".fullbox"+ID).show(); $("#c"+ID).slideToggle(300); return false; }); //commment Submint $('.comment_submit').live("click",function() { var ID = $(this).attr("id"); var comment_content = $("#textarea"+ID).val(); var dataString = 'comment_content='+ comment_content + '&msg_id=' + ID; if(comment_content=='') { alert("Please Enter Comment Text"); } else { $.ajax({ type: "POST", url: "comment_ajax.php", data: dataString, cache: false, success: function(html){ $("#commentload"+ID).append(html); document.getElementById("textarea"+ID).value=''; $("#textarea"+ID).focus(); } }); } return false; }); // Delete Wall Update $('.delete_update').live("click",function() { var ID = $(this).attr("id"); var dataString = 'msg_id='+ ID; var parent=$("#bar"+ID); jConfirm('Are you sure you want to delete this message?', 'Confirmation Dialog', function(r) { if(r==true) { $.ajax({ type: "POST", url: "delete_comment.php", data: dataString, cache: false, success: function(html){ $("#comment"+ID).slideUp(); } }); } return false; }); return false; }); </script> <style type="text/css"> body { font-family:Arial, Helvetica, sans-serif; font-size:12px; } .update_box { background-color:#D3E7F5; border-bottom:#ffffff solid 1px; padding-top:3px } a { text-decoration:none; color:#d02b55; } a:hover { text-decoration:underline; color:#d02b55; } *{margin:0;padding:0;} ol.timeline {list-style:none;font-size:1.2em;}ol.timeline li{ display:none;position:relative; }ol.timeline li:first-child{border-top:1px dashed #006699;} .delete_button { float:right; margin-right:10px; width:20px; height:20px } .cdelete_button { float:right; margin-right:10px; width:20px; height:20px } .feed_link { font-style:inherit; font-family:Georgia; font-size:13px;padding:10px; float:left; width:350px } .comment { color:#0000CC; text-decoration:underline } .delete_update { font-weight:bold; } .cdelete_update { font-weight:bold; } .post_box { height:55px;border-bottom:1px dashed #006699;background-color:#F3F3F3; width:499px;padding:.7em 0 .6em 0;line-height:1.1em; } #fullbox { margin-top:6px;margin-bottom:6px; display:none; } .comment_box { display:none;margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:50px; } .comment_load { margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:30px; font-size:12px; border-bottom:solid 1px #FFFFFF; } .text_area { width:290px; font-size:12px; height:30px; } #expand_box { margin-left:90px; margin-top:5px; margin-bottom:5px; } embed { width:200px; height:150px; } </style> </head> <body> <?php include '../../../settings.php'; ?> <div align="center"> <table cellpadding="0" cellspacing="0" width="500px"> <tr> <td> <div align="left"> <form method="post" name="form" action=""> <table cellpadding="0" cellspacing="0" width="500px"> <tr><td align="left"><div align="left"> <h3>What are you doing?</h3></div></td></tr> <tr> <td style="padding:4px; padding-left:10px;" class="update_box"> <textarea cols="30" rows="2" style="width:480px;font-size:14px; font-weight:bold" name="content" id="content" maxlength="145" ></textarea><br /> <input type="submit" value="Update" id="v" name="submit" class="comment_button"/> </td> </tr> </table> </form> </div> <div style="height:7px"></div> <div id="flash" align="left" ></div> <ol id="update" class="timeline"> </ol> <div id='old_updates'> <?php $small=mysql_query("select * from messages2 order by msg_id desc LIMIT 5"); while($r=mysql_fetch_array($small)) { $id=$r['msg_id']; $msg=$r['message']; ?> <div align="left" class="post_box"> <span style="padding:10px"><?php echo $msg.'....'.$id; ?> </span> </div> <ol> <?php //Here $id is main message msg_id value. $csql=mysql_query("select * from comments where msg_id_fk='$id' order by com_id "); $array = mysql_fetch_assoc($csql); $comment_count=mysql_num_rows($csql); if($comment_count>2) { $second_count=$comment_count-2; ?> <div class="comment_ui" id="view<?php echo $id; ?>"> <a href="#" class="view_comments" id="<?php echo $id; ?>">View all <?php echo $comment_count; ?> comments</a> </div> <?php } ?> <div id="view_comments<?php echo $id; ?>"></div> <div id="two_comments<?php echo $id; ?>"> <table width="50%"> <?php $small2=mysql_query("select * from comments where msg_id_fk='$id' order by com_id limit 2 "); while($rowsmall22=mysql_fetch_array($small2)) { $c_id=$rowsmall22['com_id']; $comments=$rowsmall22['comment']; ?> <div class="comment_actual_text"> <tr> <td style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid" valign="top"> <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse" align="left"> <tr> <td width="5%" style="VERTICAL-ALIGN: middle; TEXT-ALIGN: center"><img style="WIDTH: 30px; HEIGHT: 30px" alt="srinivas" src="http://www.gravatar.com/avatar.php?gravatar_id=7a9e87053519e0e7a21bb69d1deb6dfe" border="1" /></td> <td style="VERTICAL-ALIGN: top; TEXT-ALIGN: left"> <strong>Jarratt</strong> <?php echo $comments; ?> <br /><span style="COLOR: #a9a9a9">10 min ago - ID = <?php echo $c_id.'...'.$id;?> </span></td> </tr> </table><br /> </td> </tr> </div> <?php } ?> </table> </div> </ol> <?php } ?> </div> </td> </tr> </table> </div> </body> </html> I need to know/find out what type of Code Encryptor was used on this code. I want the exact code encryptor. Here's the code that has been encrypted: Code: <script type="text/javascript">document.write('\u003C\u0073\u0074\u0079\u006C\u0065\u0020\u0074\u0079\u0070\u0065\u003D\u0022\u0074\u0065\u0078\');</script> if you want to see more of the code, go to http://leilockheart.me That is not my code. Please someone help me find out what code encryptor was used for that code above! I need it for my website as well. The other code encryptor does not work for me; people can still decode it. Also, is there a way to decode that code? Whatever that code encryptor was, it sure worked. I have googled it and I still can't find out which one that person used. Thanks! Code: <html> <head> <script language="JavaScript" src="gen_validatorv5-.js" type="text/javascript" xml:space="preserve"></script> <script type="text/javascript"> function calc(nForm){ var inHour =parseInt( nForm.inHr.value) var inMinutes = parseInt( nForm.inMin.value); var lunchOutHour = parseInt(nForm.lunchOutHr.value); var lunchOutMinutes = parseInt( nForm.lunchOutMin.value); var lunchInHour = parseInt( nForm.lunchInHr.value); var lunchInMinutes = parseInt( nForm.lunchInMin.value); var outHour = parseInt( nForm.outHr.value); var outMinutes = parseInt( nForm.outMin.value); var linearInTime = (inHour/1)+(inMinutes/60); var linearLunchOutTime = (lunchOutHour/1)+(lunchOutMinutes/60); var linearLunchInTime = (lunchInHour/1)+(lunchInMinutes/60); var linearOutTime = (outHour/1)+(outMinutes/60); var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-hoursWorked nForm.timeWorked.value = hoursWorked+""+minutesWorked; } function calc2(nForm){ var inHour =parseInt( nForm.inHr2.value) var inMinutes = parseInt( nForm.inMin2.value); var lunchOutHour = parseInt(nForm.lunchOutHr2.value); var lunchOutMinutes = parseInt( nForm.lunchOutMin2.value); var lunchInHour = parseInt( nForm.lunchInHr2.value); var lunchInMinutes = parseInt( nForm.lunchInMin2.value); var outHour = parseInt( nForm.outHr2.value); var outMinutes = parseInt( nForm.outMin2.value); var linearInTime = (inHour/1)+(inMinutes/60); var linearLunchOutTime = (lunchOutHour/1)+(lunchOutMinutes/60); var linearLunchInTime = (lunchInHour/1)+(lunchInMinutes/60); var linearOutTime = (outHour/1)+(outMinutes/60); var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-hoursWorked nForm.timeWorked2.value = hoursWorked+""+minutesWorked; } function calc3(nForm){ var inHour =parseInt( nForm.inHr3.value) var inMinutes = parseInt( nForm.inMin3.value); var lunchOutHour = parseInt(nForm.lunchOutHr3.value); var lunchOutMinutes = parseInt( nForm.lunchOutMin3.value); var lunchInHour = parseInt( nForm.lunchInHr3.value); var lunchInMinutes = parseInt( nForm.lunchInMin3.value); var outHour = parseInt( nForm.outHr3.value); var outMinutes = parseInt( nForm.outMin3.value); var linearInTime = (inHour/1)+(inMinutes/60); var linearLunchOutTime = (lunchOutHour/1)+(lunchOutMinutes/60); var linearLunchInTime = (lunchInHour/1)+(lunchInMinutes/60); var linearOutTime = (outHour/1)+(outMinutes/60); var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-hoursWorked nForm.timeWorked3.value = hoursWorked+""+minutesWorked; } function calc4(nForm){ var inHour =parseInt( nForm.inHr4.value) var inMinutes = parseInt( nForm.inMin4.value); var lunchOutHour = parseInt(nForm.lunchOutHr4.value); var lunchOutMinutes = parseInt( nForm.lunchOutMin4.value); var lunchInHour = parseInt( nForm.lunchInHr4.value); var lunchInMinutes = parseInt( nForm.lunchInMin4.value); var outHour = parseInt( nForm.outHr4.value); var outMinutes = parseInt( nForm.outMin4.value); var linearInTime = (inHour/1)+(inMinutes/60); var linearLunchOutTime = (lunchOutHour/1)+(lunchOutMinutes/60); var linearLunchInTime = (lunchInHour/1)+(lunchInMinutes/60); var linearOutTime = (outHour/1)+(outMinutes/60); var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-hoursWorked nForm.timeWorked4.value = hoursWorked+""+minutesWorked; } function calc5(nForm){ var inHour =parseInt( nForm.inHr5.value) var inMinutes = parseInt( nForm.inMin5.value); var lunchOutHour = parseInt(nForm.lunchOutHr5.value); var lunchOutMinutes = parseInt( nForm.lunchOutMin5.value); var lunchInHour = parseInt( nForm.lunchInHr5.value); var lunchInMinutes = parseInt( nForm.lunchInMin5.value); var outHour = parseInt( nForm.outHr5.value); var outMinutes = parseInt( nForm.outMin5.value); var linearInTime = (inHour/1)+(inMinutes/60); var linearLunchOutTime = (lunchOutHour/1)+(lunchOutMinutes/60); var linearLunchInTime = (lunchInHour/1)+(lunchInMinutes/60); var linearOutTime = (outHour/1)+(outMinutes/60); var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-hoursWorked nForm.timeWorked5.value = hoursWorked+""+minutesWorked; } function calc6(nForm){ var inHour =parseInt( nForm.inHr6.value) var inMinutes = parseInt( nForm.inMin6.value); var lunchOutHour = parseInt(nForm.lunchOutHr6.value); var lunchOutMinutes = parseInt( nForm.lunchOutMin6.value); var lunchInHour = parseInt( nForm.lunchInHr6.value); var lunchInMinutes = parseInt( nForm.lunchInMin6.value); var outHour = parseInt( nForm.outHr6.value); var outMinutes = parseInt( nForm.outMin6.value); var linearInTime = (inHour/1)+(inMinutes/60); var linearLunchOutTime = (lunchOutHour/1)+(lunchOutMinutes/60); var linearLunchInTime = (lunchInHour/1)+(lunchInMinutes/60); var linearOutTime = (outHour/1)+(outMinutes/60); var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-hoursWorked nForm.timeWorked6.value = hoursWorked+""+minutesWorked; } function calc7(nForm){ var inHour =parseInt( nForm.inHr7.value) var inMinutes = parseInt( nForm.inMin7.value); var lunchOutHour = parseInt(nForm.lunchOutHr7.value); var lunchOutMinutes = parseInt( nForm.lunchOutMin7.value); var lunchInHour = parseInt( nForm.lunchInHr7.value); var lunchInMinutes = parseInt( nForm.lunchInMin7.value); var outHour = parseInt( nForm.outHr7.value); var outMinutes = parseInt( nForm.outMin7.value); var linearInTime = (inHour/1)+(inMinutes/60); var linearLunchOutTime = (lunchOutHour/1)+(lunchOutMinutes/60); var linearLunchInTime = (lunchInHour/1)+(lunchInMinutes/60); var linearOutTime = (outHour/1)+(outMinutes/60); var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-hoursWorked nForm.timeWorked7.value = hoursWorked+""+minutesWorked; } </script> </head> <body> <div align="center"> <h1> <script src='scripts/gen_validatorv5.js' type='text/javascript'></script> <script src='scripts/sfm_moveable_popup.js' type='text/javascript'></script> <style type='text/css'> .error_strings { font-family:Verdana; font-size:10px; color:#660000; } .sfm_float_error_box { position:absolute; z-index:999; cursor:default; font-family:Verdana; font-size:10px; color:#660000; background-color:#ffff66; border-style:solid; border-width:1px; border-color:#660000; } .sfm_float_box_td { padding:3px; cursor:default; font-family:Verdana; font-size:10px; color:#660000; background-color:#ffff66; } .sfm_close_box { font-family:Verdana; font-size:10px; font-weight:bold; color:#ffffff; background-color:#660000; border-width:0px; text-align:center; } .sfm_cr_box { font-family:Verdana; font-size:10px; color:#888888; border-style:solid; border-width:0px; border-color:#660000; } .sfm_cr_box a { color:#888888; } </style> Masquerade Timesheet Entry</h1> </div> <div id='timeSheet_errorloc' class='error_strings' style=''></div> <form name='timeSheet'> <table width="833" height="244" border="1" align="center"> <tr> <td width="266"><p>Sunday:</p> <p>Clock In: <label> <input name="inHr7" type="text" id="inHr7" size="10" maxlength="2"> </label>   <label> <input name="inMin7" type="text" id="inMin7" size="10" maxlength="2"> </label> <br> Lunch Out: <label> <input name="lunchOutHr7" type="text" id="lunchOutHr7" size="10" maxlength="2"> </label>   <label></label> <input name="lunchOutMin7" type="text" id="lunchOutMin7" size="10" maxlength="2"> <br> Lunch In: <label> <input name="lunchInHr7" type="text" id="lunchInHr7" size="10" maxlength="2"> </label>   <label> <input name="lunchInMin7" type="text" id="lunchInMin7" size="10" maxlength="2"> </label> <br> Clock Out: <label> <input name="outHr7" type="text" id="outHr7" size="10" maxlength="2"> </label>   <label> <input name="outMin7" type="text" id="outMin7" size="10" maxlength="2"> </label> </p> <p>Time Worked: <input type='text' name='timeWorked7' size='5' readonly> </p> </td> <td width="269"><p align="left">Monday :</p> Clock In: <label> <input name="inHr" type="text" id="inHr" size="10" maxlength="2"> </label>   <label> <input name="inMin" type="text" id="inMin" size="10" maxlength="2"> </label> <br> Lunch Out: <label> <input name="lunchOutHr" type="text" id="lunchOutHr" size="10" maxlength="2"> </label>   <label></label> <input name="lunchOutMin" type="text" id="lunchOutMin" size="10" maxlength="2"> <br> Lunch In: <label> <input name="lunchInHr" type="text" id="lunchInHr" size="10" maxlength="2"> </label>   <label> <input name="lunchInMin" type="text" id="lunchInMin" size="10" maxlength="2"> </label> <br> Clock Out: <label> <input name="outHr" type="text" id="outHr" size="10" maxlength="2"> </label>   <label> <input name="outMin" type="text" id="outMin" size="10" maxlength="2"> </label> <p>Time Worked: <input type='text' name='timeWorked' size='5' readonly> </p> </td> <td width="276"><p>Tuesday:</p> <p>Clock In: <label> <input name="inHr2" type="text" id="inHr2" size="10" maxlength="2"> </label>   <label> <input name="inMin2" type="text" id="inMin2" size="10" maxlength="2"> </label> <br> Lunch Out: <label> <input name="lunchOutHr2" type="text" id="lunchOutHr2" size="10" maxlength="2"> </label>   <label></label> <input name="lunchOutMin2" type="text" id="lunchOutMin2" size="10" maxlength="2"> <br> Lunch In: <label> <input name="lunchInHr2" type="text" id="lunchInHr2" size="10" maxlength="2"> </label>   <label> <input name="lunchInMin2" type="text" id="lunchInMin2" size="10" maxlength="2"> </label> <br> Clock Out: <label> <input name="outHr2" type="text" id="outHr2" size="10" maxlength="2"> </label>   <label> <input name="outMin2" type="text" id="outMin2" size="10" maxlength="2"> </label> </p> <p>Time Worked: <input type='text' name='timeWorked2' size='5' readonly> </p></td> </tr> <tr> <td><p>Wednesday:</p> <p>Clock In: <label> <input name="inHr3" type="text" id="inHr3" size="10" maxlength="2"> </label>   <label> <input name="inMin3" type="text" id="inMin3" size="10" maxlength="2"> </label> <br> Lunch Out: <label> <input name="lunchOutHr3" type="text" id="lunchOutHr3" size="10" maxlength="2"> </label>   <label></label> <input name="lunchOutMin3" type="text" id="lunchOutMin3" size="10" maxlength="2"> <br> Lunch In: <label> <input name="lunchInHr3" type="text" id="lunchInHr3" size="10" maxlength="2"> </label>   <label> <input name="lunchInMin3" type="text" id="lunchInMin3" size="10" maxlength="2"> </label> <br> Clock Out: <label> <input name="outHr3" type="text" id="outHr3" size="10" maxlength="2"> </label>   <label> <input name="outMin3" type="text" id="outMin3" size="10" maxlength="2"> </label> </p> <p>Time Worked: <input type='text' name='timeWorked3' size='5' readonly> </p></td> <td><p>Thursday:</p> <p>Clock In: <label> <input name="inHr4" type="text" id="inHr4" size="10" maxlength="2"> </label>   <label> <input name="inMin4" type="text" id="inMin4" size="10" maxlength="2"> </label> <br> Lunch Out: <label> <input name="lunchOutHr4" type="text" id="lunchOutHr4" size="10" maxlength="2"> </label>   <label></label> <input name="lunchOutMin4" type="text" id="lunchOutMin4" size="10" maxlength="2"> <br> Lunch In: <label> <input name="lunchInHr4" type="text" id="lunchInHr4" size="10" maxlength="2"> </label>   <label> <input name="lunchInMin4" type="text" id="lunchInMin4" size="10" maxlength="2"> </label> <br> Clock Out: <label> <input name="outHr4" type="text" id="outHr4" size="10" maxlength="2"> </label>   <label> <input name="outMin4" type="text" id="outMin4" size="10" maxlength="2"> </label> </p> <p>Time Worked: <input type='text' name='timeWorked4' size='5' readonly> </p></td> <td><p>Friday:</p> <p>Clock In: <label> <input name="inHr5" type="text" id="inHr5" size="10" maxlength="2"> </label>   <label> <input name="inMin5" type="text" id="inMin5" size="10" maxlength="2"> </label> <br> Lunch Out: <label> <input name="lunchOutHr5" type="text" id="lunchOutHr5" size="10" maxlength="2"> </label>   <label></label> <input name="lunchOutMin5" type="text" id="lunchOutMin5" size="10" maxlength="2"> <br> Lunch In: <label> <input name="lunchInHr5" type="text" id="lunchInHr5" size="10" maxlength="2"> </label>   <label> <input name="lunchInMin5" type="text" id="lunchInMin5" size="10" maxlength="2"> </label> <br> Clock Out: <label> <input name="outHr5" type="text" id="outHr5" size="10" maxlength="2"> </label>   <label> <input name="outMin5" type="text" id="outMin5" size="10" maxlength="2"> </label> </p> <p>Time Worked: <input type='text' name='timeWorked5' size='5' readonly> </p></td> </tr> </table> <table width="559" border="1" align="center"> <tr> <td width="277"><p>Saturday:</p> <p>Clock In: <label> <input name="inHr6" type="text" id="inHr6" size="10" maxlength="2"> </label>   <label> <input name="inMin6" type="text" id="inMin6" size="10" maxlength="2"> </label> <br> Lunch Out: <label> <input name="lunchOutHr6" type="text" id="lunchOutHr6" size="10" maxlength="2"> </label>   <label></label> <input name="lunchOutMin6" type="text" id="lunchOutMin6" size="10" maxlength="2"> <br> Lunch In: <label> <input name="lunchInHr6" type="text" id="lunchInHr6" size="10" maxlength="2"> </label>   <label> <input name="lunchInMin6" type="text" id="lunchInMin6" size="10" maxlength="2"> </label> <br> Clock Out: <label> <input name="outHr6" type="text" id="outHr6" size="10" maxlength="2"> </label>   <label> <input name="outMin6" type="text" id="outMin6" size="10" maxlength="2"> </label> </p> <p>Time Worked: <input type='text' name='timeWorked6' size='5' readonly> </p></td> <td width="266"><p> <input type='text' name='timeWorked8' size='5' readonly> </p> <p> <input type='button' value="Calculate" onClick="calc(this.form),calc2(this.form),calc3(this.form), calc4(this.form),calc5(this.form),calc6(this.form),calc7(this.form),calc8(this.form)"> <input type="button" name="reset_form" value="Clear Forms" onClick="this.form.reset();"> </p> <div align="left"> <p> </p> <p>Total Time Worked:</p> <label></label> </div></td> </tr> </table> <p align="left"> </P> <p align="left"><br> <br> <br> <br> </P> </form ><p> </p> <p> </p> </body> </html> First off, I know there must be an easier way to code this. Also, I would like to make sure validation, where they only can input numbers but whenever I try, it doesn't work at all. Hi, I can not this code in my web page. Could you please check it ans say how I can run. I try the code using html test page but failed. <script language="javascript"><!-- document.write('<iframe src="http://www.juenpetmarket.com/moduls/banner/banner_reklamiframe.aspx?ID=U64k1S3Gm4WOeKF497FTWw%3d%3d&position=dikey&urunSayisi=1" height="240" width="100" frameborder="0" scrolling="no" style="TOP: 20px;right=0;Position:Absolute;Z-INDEX: 999;visibility:visible" id="reklamFrm" allowtransparency="true"></iframe>'); //--></script> <script language="javascript" src="http://www.juenpetmarket.com/moduls/banner/WaterMalk.js"></script> all help are really appreciated ========================================== <%@ page language= "Jscript" %> <%@ import namespace= "system" %> <%@ import namespace= "system.data" %> <%@ import namespace= "system.data.OleDb" %> <%@ register tagprefix= "Header" Tagname="ImageHeader Src= "imageHeader.ascx""%> <html> <body> <script language= "Jscript" runat = "server"> function page_load (sender : Object, events : EventArgs) { if(!IsPostBack) { var DataBaseConnection : OleDbConnection = new OleDbConnection ( ConfigurationSettings.AppSettings ("ConnectionString" ) ); var queryString : System.String = "SELECT customerid, [companyname] FROM customers"; dataBaseConnection.Open(); var dataBseCommand : OleDbCommand = new OleDbCommand ( queryString, dataBaseConnection ); var dataReader = dataBaseCommand.ExecuteReader(); while ( dataReader.Read()) nameList.Items.Add( dataReader.GetString( 0 ) + ", " + dataReader.GetString ( 1 )); dateBaseConnection.Close(); } else { dataGrid.DataSource = GetData(); dataGrid.DataBind(); } } function GetData() : ICollection { Var set : DataSet = new DataSet(); Var dataBaseConection: OleDbconnection = new OleDbconnection( ConfigurationSettings.AppSettings( "ConnectionString" ) ); var customerID : int = nameList.SelectedIndex + 1; var queryString : String = "SELECT [companyname] from customers WHERE " + "customerid = " + customerID + ")"; var databaseCommand :OleDbCommand= new OleDbCommand( querystring, dataBaseConnection); var dataadapter : OleDbdataadapter= new Oledbdataadapter databaseconnection); dataAdapter.Fill( set ); dataBaseCommand.Connection.Close(); var dataView : DataView = new DataView( set.Tables[ 0 ] ); return dataView; } </script> <form runat = "server"> <Header:ImageHeader id = "head" runat ="server"> </Header:ImageHeader> <br /> Company Details: <aspropList id = "nameList" runat = "server" Width = "158px" Height = "22px"> </aspropList> <asp:button id = "button" text = "select" runat = "server"> </asp:button> <p> <asp"DataGrid id = "dataGrid" runat = "server"> </aspataGrid> </p> </form> </body> </html> Hi Guys, I have this JS code and it is really working just fine ... tit gives me all record based on what is selected on projectname down.. what i need to add is another dropdown to be able to filter by unique "BU" just fyi how arrays are build here : if we take projectid[0] = 112 projectname[0] = MyProjectname ID[0]= 102 BU[0]= Department 1 DESCRIPTION[0]= this is for department 1 NUM_T[0]= 5 MTH[0]= Oct-2011 NUM_F[0]= 2 NUM_M[0]= 3 for the same project i can have many department projectid[0] = 112 projectname[0] = MyProjectname ID[0]= 103 BU[0]= Department 2 DESCRIPTION[0]= this is for department 2 NUM_T[0]= 6 MTH[0]= Nov-2011 NUM_F[0]= 3 NUM_M[0]= 5 and so on So i want to get the first DDL showing all distinct project ..which is done so far - I am looking to add a 2nd DDL that includes all distinct BU "departments" under same project .. any ine can help on how to get that ? thanks below is my code : [ code ] <SCRIPT LANGUAGE="JavaScript"> var uniqueProjectIds = [], opt, temp = []; for(var i = 0; i < PROJECTID.length; i++) { if(uniqueProjectIds[PROJECTID[i]] == null) { uniqueProjectIds[PROJECTID[i]] = []; opt = document.createElement('option'); opt.text = PROJECTNAME[i]; opt.value = PROJECTID[i]; document.forms[0].cmbProjects.add(opt,undefined); } temp = uniqueProjectIds[PROJECTID[i]]; temp.push(i); uniqueProjectIds[PROJECTID[i]] = temp; } function showDetails(val) { var tbl = document.getElementById('tblDetails'); while(tbl.rows.length != 1) { tbl.tBodies[0].deleteRow(tbl.rows.length-1); } if(val != '-1') { var dtls = uniqueProjectIds[val]; for(var i = 0; i < dtls.length; i++) { var row = tbl.tBodies[0].insertRow(tbl.rows.length); row.insertCell(0).innerHTML = ID[dtls[i]] row.insertCell(1).innerHTML = BU[dtls[i]]; row.insertCell(2).innerHTML = DESCRIPTION[dtls[i]]; row.insertCell(3).innerHTML = NUM_T[dtls[i]]; row.insertCell(4).innerHTML = MTH[dtls[i]]; row.insertCell(5).innerHTML = NUM_F[dtls[i]]; row.insertCell(6).innerHTML = NUM_M[dtls[i]]; } } } [ /code ] I am working on a basic function to determine eiligibility for a loan. I am looking to have the html and js as separate files. I am missing something or not connecting the dots correctly. Any help would be appreciated. .htm Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="new_file.js"></script> <title>New Web Project</title> <style type="text/css">body {background-color: #CCCCCC}</style> </head> <body> <h1>Loan Application</h1> <form id="Loan Application" action="form_action.asp"> <fieldset> <legend>Please enter the following information:</legend> <label for="Annual Income">Annual Income</label> <br /> <input type="text" name="annual income" id="annual income" value="40000" /> <br /> <label for="credit">Credit Score</label> <br /> <input type="text" name="credit" id="credit" value="500" /> <br /> <label for="education">Education Level</label> <br /> <select name="education" id="education"> <option value="High School">High School</option> <option value="Associate's Degree">Associate's Degree</option> <option value="Bachelor's Degree">Bachelor's Degree</option> <option value="Postgraduate Degree">Postgraduate Degree</option> </select> <br /> <br /> <input type="button" value="Calculate" onclick="result()" /> <br /> </fieldset> <DIV id="output"> </DIV> </form> </body> </html> .js PHP Code: function loanApp(income, credit, education){ if(income >= 0 || income <= 40000){ return 1; } else { if(income >=40001 || income <= 80000){ return 3; } else { return 5; }} if(credit >= 300 || credit <= 500){ return 1; }else if(credit >= 501 || credit <=650){ return 3; }else { return 5; }} switch (education) { case "High School": result = 1; break; case "Associate's Degree": result = 2; break; case "Bachelor’s Degree": result = 3; break; case "Postgraduate Degree": result = 5; default: result = "That was not a valid selection."; } function result(answer){ var answer = income + credit + education; if (totalScore >= 3 || totalScore <= 7) { document.getElementById(output).("I'm sorry but your loan has been declined."); } else if (totalScore >= 8 || totalScore <= 10) { document.getElementById(output).("The loan is approved at 8.5% interest rate."); } else { document.getElementById(output).("Your approved at a 7% interest rate."); return answer; } } |