JavaScript - Help Finishing My Code
I dont know how im gonna achieve this but i have an image slider i made (images slide of to the right, new one comes on from the left) however i need them to disappear when they leave the container there in. If anyone can help me code this would be greatly appreciated . Heres what i have. Also it wont properly cycle through my array so if anyone can help me fix that would be great too .
Code: <h1>Image slider</h1> <span id="number"></span> <div id="sliderContainer"> <div id="leftButton"><a href="#" id="slideLeft"><</a></div> <div id="rightButton" onclick="moveRight()">></div> <div id="gallery"><img id="theImage" height="400" style="position:relative;left:0px;" /></div> </div> <script type="text/javascript"> var theImages=["images/a.jpg","images/b.jpg","images/c.jpg", "images/d.jpg", "images/e.jpg"]; // Build the array of text var arrayRows = theImages.length; //Get the length of the array (Note: This starts at 1 not 0 like the array) var i=0; //Set a counter document.getElementById('theImage').src = theImages[0]; document.getElementById('number').innerHTML = arrayRows - 1; function moveRight1() { var pp = document.getElementById("theImage"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveRight1()",1); // 1 controls the speed lft = lft+15; // move by 15 pixels pp.style.left = lft+"px"; if (lft > 600) { // left edge of image past the right edge of screen clearTimeout(tim); pp.style.left = "-600px"; i++; if (i >= (arrayRows - 1)) { i = 0; } moveLeft1(); } } function moveLeft1() { document.getElementById('theImage').src = theImages[i]; var pp = document.getElementById("theImage"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveLeft1()",1); // 1 controls the speed lft = lft+15; // move by 15 pixels pp.style.left = lft+"px"; if (lft > 0) { // left edge of image past the right edge of screen pp.style.left = "0px"; clearTimeout(tim); } document.getElementById('number').innerHTML = i; } </script> Also any general improvements will be good too Similar TutorialsI am trying to create a simple shoot em up on java and it is due by tomorrow 5/2. I need help making the gun I have created, shoot up to 10 bullets using the space bar. Also, I need some kind of either bullet countdown bar or something to show the shooter the number of bullets that he has left to shoot out of 10. So far I have created the Ufo's that bounce around the screen randomly and the gun that moves along the bottom using the arrow keys. When a Ufo huts the gun the game ends and goes to a blank screen. Here is what I have so far: Code: //Shoot.java import acm.graphics.*; import acm.program.*; import java.awt.event.*; import java.awt.*; import acm.util.*; public class Shoot extends GraphicsProgram { public static final int APPLICATION_WIDTH = 800; public static final int APPLICATION_HEIGHT = 500; final int AW=APPLICATION_WIDTH; final int AH=APPLICATION_HEIGHT; final int WAIT=5; final int MV_AMT=5; final int JUMP_AMT=100; final int U_SIZE=30; int xMove,yMove; UFO u1,u2,u3; public void init() { u1=new UFO(); u2=new UFO(); u3=new UFO(); RandomGenerator rg= new RandomGenerator(); int rand1= rg.nextInt(0,AW-50); int rand2= rg.nextInt(0,AW-75); int rand3= rg.nextInt(0,AW-100); add(u1,rand1,0); add(u2,rand2,0); add(u3,rand3,0); xMove=yMove=0; addKeyListeners(); }//init public void keyPressed(KeyEvent e) { int key = e.getKeyCode( ); if (key == KeyEvent.VK_RIGHT) { xMove = MV_AMT ; } else if (key == KeyEvent.VK_LEFT) { xMove = -MV_AMT ; } } //keyPressed public void run() { RandomGenerator rg =new RandomGenerator(); GRectangle u1Box, u2Box, u3Box, g1Box; int xMove1=1,xMove2=1,xMove3=1; int yMove1=1,yMove2=0,yMove3=1/4; boolean u1Done=false, u2Done=false, u3Done=false; GUN g1=new GUN(); add(g1,300,480); xMove=yMove=0; addKeyListeners(); waitForClick(); while(true) { u1.move(xMove1,yMove1); u2.move(xMove2,yMove2); u3.move(xMove3,yMove3); u1Box=u1.getBounds(); u2Box=u2.getBounds(); u3Box=u3.getBounds(); g1Box=g1.getBounds(); pause(WAIT); g1.move(xMove,yMove); xMove=yMove=0; //intersections if(u1Box.intersects(g1Box)==true) {g1.setVisible(false); u1.setVisible(false); u2.setVisible(false); u3.setVisible(false); break; } if(u2Box.intersects(g1Box)==true) {g1.setVisible(false); u1.setVisible(false); u2.setVisible(false); u3.setVisible(false); break; } if(u3Box.intersects(g1Box)==true) {g1.setVisible(false); u1.setVisible(false); u2.setVisible(false); u3.setVisible(false); break; } //at top of window if (u1.getY( ) == 0) { yMove1 = -yMove1 ; } if (u2.getY( ) == 0) { yMove2 = -yMove2 ; } if (u3.getY( ) == 0) { yMove3 = -yMove3 ; } //at left or right side if ((u1.getX( ) <= 0) || (u1.getX( ) + U_SIZE >= AW)) { xMove1 = -xMove1 ; } if ((u2.getX( ) <= 0) || (u2.getX( ) + U_SIZE >= AW)) { xMove2 = -xMove2 ; } if ((u3.getX( ) <= 0) || (u3.getX( ) + U_SIZE >= AW)) { xMove3 = -xMove3 ; } //at bottom of window if (u1.getY( ) == 450) { yMove1 = -yMove1 ; } if (u2.getY( ) == 450) { yMove2 = -yMove2 ; } if (u3.getY( ) == 450) { yMove3 = -yMove3 ; } } } } Thank you so much Courtney 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 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> 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> 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! i was trying to make a code, but through trial and error i made this code var word=prompt("enter a sentence below we will find where the first A or a starts"); document.write(word.indexOf("A")); document.write(word.indexOf("a")); what does this code do(if you cant tell, its in javascript) i wanted it so someone could type a sentence in a prompt box and it would tell them where the first a or A is in the sentence. Hello I have no knowlege in JS and I need your help I have this code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Setting cookie and passing to other page in url</title> <script language="javascript" type="text/javascript"> var i = 0; var ids = new Array(); function setCookie(c_name) { c_name += "[]" + i++; ids[i] = c_name; var value = document.getElementById("i1").value; document.cookie = c_name + "=" + escape(value); } function getVarNPost() { var valuestoPost = ""; for (x in ids) { c_start = document.cookie.indexOf(ids[x] + "="); if (c_start != -1) { c_start = c_start + ids[x].length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end = document.cookie.length valuestoPost += ids[x] + "=" + unescape(document.cookie.substring(c_start, c_end)) + "&"; } } window.location = "http://www.classimoveisrn.com/hebrew/js_test.php?" + valuestoPost; } </script> </head> <body> <form id="f1"> <input type="text" id="i1" /> <input type="button" id="submit" value="submit" onclick="setCookie('id')" /> </form> <input type="submit" id="post" value="submit" onclick="getVarNPost()" /> </body> </html> the output in the link will be: domain.com?id[]0=123&id[]1=345....id[]i=*** Because I need to use SQL after I wanted to know if I can get an array output in the link I need my link to be like this: domain.com?ids[]=123&ids[]=456&ids[]=789 ... cus I need to query like this Code: $ids = array_map('intval', $_GET['ids']); $sql = "SELECT * FROM foo WHERE id IN (" . implode(',', $ids) . ")"; Any idea? 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; } } Sir please tel me how to validate,when we add dynamic rows using javascript and for that rows we have to validate.I will send the code please do some help. Code: <html> <head> <script type="text/javascript"> function validate() { var id=document.getElementById("ide"); if(id.value.length==0) { //alert("invalid id"); id.focus(); return false; } var b=document.getElementById("uname"); if(b.value.match(/^[a-zA-Z]{1,}$/)==null) { //alert("invalid name"); b.focus(); return false; } var c=document.getElementById("add"); if((c.value.length<15)||(c.value.length>60)) { //alert("invalid address"); c.focus(); return false; } var x=document.getElementsByName("email"); for(var i=0;i<=x.length;i++) { if (x[i].value=="") { alert("Please fillup atleast one textbox"); x[i].focus(); return false; } //var d=document.getElementsByTagName("email"); var e=document.getElementById("phone"); if(e.value.length==0) { alert("invlaid phone"); e.focus(); return false; } var f=document.getElementById("city"); if(f.value.length==0) { alert("invlaid city"); f.focus(); return false; } return true; } </script> </head> <body onLoad="document.test.ide.focus();"/> <form name="test"> <tr> ID:<input type="text" name="ide" id="ide" /> NAME:<input type="text" name="uname" id="uname" value="" /> <textarea name="add" rows="3" cols="10" id="add" ></textarea> </tr> </table> <br> <input type="submit" value="Submit" onClick="return validate();"> </body> <meta http-equiv="Content-Script-Type" content="text/javascript"> <script type="text/javascript"> var clone; function cloneRow(){ var rows=document.getElementById('mytab').getElementsByTagName('tr'); for(var count=0;count<=rows.length;count++) { onclick=validate(); } var index=rows.length; clone=rows[index-1].cloneNode(true); var inputs=clone.getElementsByTagName('input'), inp, i=0 ; while(inp=inputs[i++]){ inp.name=inp.name.replace(/\d/g,'')+(index+1); } } //onload=validate(); function addRow(){ var tbo=document.getElementById('mytab').getElementsByTagName('tbody')[0]; tbo.appendChild(clone); cloneRow(); //tbo.validate(); } onload=cloneRow; </script> </head> <body> <form> <table id="mytab"> <tr> <td>Email</td><td><input type="text" name="email" id="email" value=""></td> <td>Phone No.</td><td> <input type="text" name="phone" id="phone" value=""></td> <td>City</td><td> <input type="text" name="city" id="city" value=""></td> </tr> </table> <br> <input type="button" value="Add a new row" onclick="addRow()"> </form> </body> </html> Hi, im completely new here and to JS. I have a project due where i have to write code to display the current time and date on an index webpage we are working on throughout the year at the university i go to. My problem is that when i view my page, it displays the date properly as i have to for class, but says the word 'undefined' immediately afterwards on my webpage. This is the page we are working on: http://unixweb.kutztown.edu/~lsant894/ can someone please look at my source and tell me why im getting this 'undefined' displayed on my page? Ive searched all day and cant find a helpful answer anywhere. I am new to HMTL and to programming itself. I joined this forum to see what I could learn. Please have a little patience with me. I recently purchased a program called WWW File Share Pro. I am going to use this program to share files with members of my family (documents, photos, etc.). The following "snipets" (?) of code appear in the HTML options of the WWW File Share Pro program itself (see attached image 9-13-2008 9-02-56 AM): Click <a href="JavaScript:history.back()"><<<Back</a> or <a href="JavaScript:history.back()"><img src="/icon15.gif" width="16" eight="16" border="0"></a> to go back. Click <a href="/">Home</a> to visit homepage. Click <a href="/upload1.htm">Upload</a> to upload file. Immediately after setting up and running the program, I discovered that there was NO way to actually "log off" or "log out" of the program when the user completes whatever tasks he/she so desires. I have attached images of the "html options" page, the "login" screen (IP address obliterated), and the "user" screen. The only options available to the user are as follows (see image 9-13-2008 9-07-54 AM): "Back" "Home" "Upload" I would like to add a "Log Off" or "Log Out" option so that the user could click a link to log out, instead of just closing the web page itself. Is there anyone on this forum that could assist me with adding the proper code to make a log out link? Is it even possible? I would also like to learn more about HTML programming. Can someone recommend a good book on HTML? I don't really understand that much about HTML, so I'll definitely need a book geared to the absolute beginner. Any assistance with this would be much appreciated. Thanks! Joseph Y. My code used to work but suddenly stopped working and I have no idea why. It is javascript embedded in an html document. Code: <script language="JavaScript1.1"> var slideimages = new Array() var slidelinks = new Array() function slideshowimages() { for (i = 0; i < slideshowimages.arguments.length; i++) { slideimages[i] = new Image() slideimages[i].src = slideshowimages.arguments[i] } } function slideshowlinks() { for (i = 0; i < slideshowlinks.arguments.length; i++) slidelinks[i] = slideshowlinks.arguments[i] } function gotoshow() { if (!window.winslide || winslide.closed) winslide = window.open(slidelinks[whichlink]) else winslide.location = slidelinks[whichlink] winslide.focus() } </script> From body: <a href="javascript:gotoshow()"><img class="dropshadow"src="images/slideshow_1.gif" name="slide" border=0 width=240 height=180></a> <script> //configure the paths of the images, plus corresponding target links slideshowimages("images/slideshow_1.gif", "images/slideshow_2.gif", "images/slideshow_3.gif", "images/slideshow_4.gif", "images/slideshow_5.gif") //configure the speed of the slideshow, in miliseconds var slideshowspeed = 3000 var whichlink = 0 var whichimage = 0 function slideit() { if (!document.images); return document.images.slide.src = slideimages[whichimage].src whichlink = whichimage if (whichimage < slideimages.length - 1); whichimage++else whichimage = 0 setTimeout("slideit()", slideshowspeed); } slideit() </script> Any help would be greatly appreciated. Hey everyone. I'm getting an error on line 30 which is --- onclick=\"document.getElementById('box').style.visibility='hidden';return false;\">Close</a>"; --- in the code. I can't see anything wrong with it, but the code does not function. I was wondering if anyone could lend a hand. Thank you very much. Here is the 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>Form Help</title> <script type="text/javascript"> /* <![CDATA[ */ function showHelp(elementId) { var curElement = document.getElementById(elementId); var helpElement = document.getElementById("box"); } switch (elementId) { case "username": helpElement.innerHTML = "Enter a unique user name that is between 5 and 12 characters."; break; case "password": helpElement.innerHTML =" Enter a password between 6 and 10 characters that contains both upper and lowercase letters and at least one numeric character."; break; case "password_confirm": helpElement.innerHTML =" confirm your selected password."; break; case"challenege": helpElement.innerHTML ="Enter your Mother's maiden name. This value will be used to confirm your identity in the even that you forget your password."; break; } helpElement.innerHTML +=<a href='' onclick=\"document.getElementById('box').style.visibility='hidden';return false;\">Close</a>"; document.getElementById("box").style.visibility = "visible"; document.getElementById("box").style.left = curElement.offsetWidth + 20 + "px"; document.getElementById("box").style.top = curElement.offsetTop + "px"; } /* ]]> */ </script> </head> <body> <h1>Form Help </h1> <form action="" method="get" enctype="application/x-www-form-urlencoded"> <p><strong>Username</strong><br /> <input type="text" id="username" size="50" onmouseover="this.style.cursor='help'" onclick="showHelp(this.id)" /></p> <p><strong>Password</strong><br /> <input type="password" id="password" size="50" onmouseover="this.style.cursor='help'" onclick="showHelp(this.id)" /></p> <p><strong>Confirm password</strong><br /> <input type="password" id="password_confirm" size="50" onmouseover="this.style.cursor='help'" onclick="showHelp(this.id)" /></p> <p><strong>What is your mother's maiden name?</strong><br /> <input type="password" id="challenge" size="50" onmouseover="this.style.cursor='help'" onclick="showHelp(this.id)" /></p> </form> <div id="box" style="position: absolute; visibility: hidden; width: 250px; background-color:#FFFFC0; font:Comic Sans MS; color: #A00000; border:1px dashed #D00000"></div> </body> </html> |