JavaScript - Javascript Ignoring My Code? Is This Real Life?
in the function emailTest in this code I can't seem to get the FIRST if statement to pass even if I put 1 in the in the email.value text box.
even if i change the if condition to (email.value=="1") or (email.value=="a") and make the email.value text field equal respectively, IT STILL WON'T PASS only if I do (1==1) will it work. ----some background---- I was making a javascript form checker and i needed to test if the email field was an email. First I tried using an isEmail function. Didn't work. But the funciton seemed legitimate. I tinkered for hours trying to find glitches (it's simple regular expressions... i mean how hard could I screw it up?) and then eventually made the function return true by default so that the function would do nothing more but return true. Even when the function JUST returned true. (i also tried just returning 1) it still didn't pass. Then I took the function out of the if statement all together and tried the regular expression test in the if function. that didn't work. Now I'm trying to compare the variable directly to something simple. AND IT STILL DOESN'T WORK. WHAT is going on here people? REALLY ... I mean REALLLY/!?!? I've been programming for 7 GD years of my GD life (not javascript honestly) and SIMPLE CODE SHOULDN'T FAIL THIS HARD. Code: function emailTest() { if (email.value==1) { emailErrorBox.innerHTML="Please insert a valid email"; emailSuccessBox.innerHTML=""; } if (email.value.length>0 && email.focus) { emailErrorBox.innerHTML="";emailSuccessBox.innerHTML=""; request.abort(); var url = "/unseen/checkIfEmailExist.php?email=" + email.value; request.open("GET", url, true); request.onreadystatechange = updateEmailCheck; request.send(null); } if (email.value.length===0) {emailErrorBox.innerHTML="Please insert an email";emailSuccessBox.innerHTML="";} } If you go to http://freetexthost.com/dgbgshkzkj that is my code. It's a lot. I can't just give you a portion because I think it's something on the large scope that is screwing me up. This entire thing has me furious because IT IS SIMPLE CODE THAT REFUSES TO WORK... LITERAL REFUSAL THE COMPUTER JUST SAID NO NO NO NO. I am SERIOUSLY trying to get rolling on this project but some hidden syntax of javascript is blocking me from having these functions work correctly Similar TutorialsOk Need Help Here. As I post earlier how to detect firefox before let the user in some guys just disable javascript and went in I finding solution i think of it but i dun know the code not sure is it working Script that allow the browser to check weather javascript is ON if not cannot grant access to the page . Another thing is by using a image means when i enter the site it will show a image i will need to click it before it enter the content of the pages i think that a javascript code i seen it somewhere else about months ago. 1 down vote favorite I do have the countdown script (see link below) to display the time between current time and the date given in real-time. However, I want to achieve to display the time difference between a given start and end time. Right now, it calculates from the current server time to the end time. I want to be able to set up my own start time and end time. Here is what I have: http://jsfiddle.net/BgEtE/ thank you for help Code: for(i=0;i<document.getElementsByName('checkresult_".$i."').length;++i){ if(document.getElementsByName('checkresult_".$i."')[i].checked){ thisurlext+=document.getElementsByName('checkresult_".$i."')[i].value; checkedlength++; if(i+1<document.getElementsByName('checkresult_".$i."').length){ if(document.getElementsByName('checkresult_".$i."')[i+1].checked){ thisurlext+='+'; } } } }; Let's say I check verses 1, 2, 3, 6 I want the Javascript not to ignore the + between the 3 and the 6: Code: <div id="txt_kjv0_1_1_0" style="float: left; background-color: rgb(234, 232, 200); margin: 0px; width: 178px; height: 497px; border: 1px solid rgb(122, 16, 16); padding: 5px 5px 0px; overflow-y: auto; overflow-x: hidden;"> <input id="sc0" value="kjv" type="hidden"> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_0" name="checkresult_0" onclick="" value="1" type="checkbox"><span style="font-weight: bold; margin: 2px;">1</span>In the beginning God created the heaven and the earth.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_1" name="checkresult_0" onclick="" value="2" type="checkbox"><span style="font-weight: bold; margin: 2px;">2</span>And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_2" name="checkresult_0" onclick="" value="3" type="checkbox"><span style="font-weight: bold; margin: 2px;">3</span>And God said, Let there be light: and there was light.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_3" name="checkresult_0" onclick="" value="4" type="checkbox"><span style="font-weight: bold; margin: 2px;">4</span>And God saw the light, that it was good: and God divided the light from the darkness.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_4" name="checkresult_0" onclick="" value="5" type="checkbox"><span style="font-weight: bold; margin: 2px;">5</span>And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_5" name="checkresult_0" onclick="" value="6" type="checkbox"><span style="font-weight: bold; margin: 2px;">6</span>And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.</p> Hi all, are there any tags i can use that will tell the parser somehow to ignore whitespace in the HTML section? The html and jave script is pasted into a custom page widget that can interpret the code, the problem is that my indentation and general coding formatting as i am writing it in my editor is also somehow being translated in the rendering - it seems mostly to be the linebreaks, in fact i would say it is only the line breaks, so the layout is appearing spread across too many lines for example, instead of neat and tight together, which is what i see in a browser. I realise this is probably the parser implementation at the application end, but can i get around this directly myself? I cannot use xml or xslt to get around this, i can only write direct html or java into this custom widget. I need to figure out a way to manipulate the arguments or functions or something somehow to have overloaded functions in JS. All I have found so far is people making like a switchboard function that directs the arguments based on the data, but not true overloading in that there is something like Function(input1) Function(input1,input2) Function(input1,input2,input3) And then you could call it with Function(x,y) or like Function(x,y,z) and hit the different functions. Any ideas? Edit: I was told to look at Functional Prototyping, which I understand the prototyping to be basiclly the parent from which others are made from. I don't see how it fits with overloading. Code: import java.util.Scanner; //This program does math public class Final { public static void main(String []args) { Scanner in=new Scanner(System.in); System.out.println("One last test"); System.out.print("Enter your birthday (mm/dd/yyyy): "); String roar=in.nextLine(); int n1=Integer.parseInt(roar); String date; String month, day, year; String ox=in.nextLine(); String[] s = ox.split("/"); for( String str : s); System.out.println("You were born on"+day+month+year); } } That is what i have so far, but i need to declare the day, month and year..can anyone help me? Okay i started a cople of days dont have experience in coding on JavaScript I need to make search button like this ) but i doesn't work. The idea is i add words or something to an array and after i enter the word or something press search and it gives the position in array. Code: var m = new Array(); function add() { var q = document.getElementById('mEntry'); var temp = q.value ; m.push(temp); } function test() { } function search() { var d = document.getEntryById('searchEntry'); var compare = d.value; var i=0; for (i=0;i<=m.lenght;i++) { if( m[i] = compare) document.write(i); } } ------------- This works just fine ) Code: var m = new Array(); function add() { var q = document.getElementById('mEntry'); var temp = q.value ; m.push(temp); } function test() { } function search() { var sEntry = document.getElementById('searchEntry'); var key = sEntry.value ; for(i in m) { if(m[i] = key) {var answer = i;} } document.write(answer); } Hi How to hide the real url and dispaly to specific url on a website. i.e. http://www.myapp.com/information.jsp is real url and want to dispaly http://www.myapp.com/ URL on browser. I will display as static URL instaead of real url. Please give an idea sugegstion how to do this bcoz I m new in JS. Thanks Lalit Hi everyone, hope you can help. I've got a JS events calendar on my website, and on one of the entries I want the ticket link not to appear until a certain time & date (9:30am, Fri 29 Apr 2011, UTC+1). I've written the code for this to work: Code: var releasetime = 1304065800000 var currentdate = new Date() var currenttime = currentdate.getTime() if (currenttime >= releasetime){ document.write("<a href=\"ticket link\" rel="nofollow" target=\"_blank\">BUY TICKETS</a>") } And that's all good and working fine. EXCEPT, because it's taking the time & date from the local machine, all the user has to do is change the date on his PC to be able to see the ticket link. Is there any way to get the *actual* date & time? Thanks Cliff I need to make a counter that counts up (preferably in real time but not crucial). Ideally, it would count up by 9 dollars per second and go to the hundred millions. Thanks in advance! One that I have seen is at www.costofwar.com This is in real time, but that feature is not crucial. Hello, I have an existing php contact form which incorporates php validation (required name with only characters, valid email address format, and minimum message length) and re-captcha. I would like to add some "real time" validation to the fields on my form (there are 3 fields - name, email and message) before the "Submit" button is pressed. For example when the user tabs from one text box to the next but hasn't filled in the required information. I am totally new to any type of java, but am I right in thinking I need either JavaScript, Ajax or JQuery to perform real-time validation? If so, which should I be looking into and are there any basic examples of form validation? I want to keep my pup validation as I'm aware that php is client-side but still needed as people can turn Java off in their web browsers. Any tips and pointers will be very much appreciated! Thankyou, Tom Hi guys, as you can see i am newbie.. So ive been working with javascipt and html for about 2 days now. What im trying to do it make a really annoying website kind of like www.mudkipz.ws [go at your own risk], the site is a youtube video of mudkip pokemon that are really annoying they just say Mud-kip for about 9 minutes.. once you try to exit, messages pop up saying "Mud" And "Kip" After Clicking "ok" Its a Loop That goes on for ever! im trying to make something like this on dreamweaver but i have very little experience! Does anyone know how i could be able to make it so it can say [ "hahah i got you!" | |"Only way to exit is by going to this link" | | "Link" | |___________[ok]____________________ | Edit: I got the exit pop up message to work, now i just need the loop code! Any idea of how to put a link in the exit pop up message? Hey guys, Im kind of a newb and i need help with this dice game im trying to build to help me learn javascript. If you open up the code up in your browser and click the roll button, it will clear everything and write var a in the top left corner. What i am trying to do is write the var a into the text box. any suggestions?? [CODE] <html> <head> <script type="text/javascript"> </script> <style type="text/css"> body { background-image: url(http://projectraw.files.wordpress.com/2010/02/background_brick_wall.jpg); } h1 { font-family:"sans-serif",tahoma; background-repeat: no-repeat; color:white; } p { color:white; font-family:"sans-serif",tahoma; font-weight:900; } </style> </head> <body> <center><h1>Ghetto Dice Project</h1></center> <center> <p> Hand coded with care by Tanner Beck </p> </br> </br> </br> </br> </br> </br> </br> </br> </br> </br> <p> <center> <table BGCOLOR="#888888" BORDER="3" CELLPADDING="5"> <tr> <input type="text" name="number" size="4" value=a> </tr> </br> <tr> <button onclick=" a=(Math.floor(Math.random()*13)); document.write(a)">ROLL</button> </tr> </table> </br> </center> </p> </body> </html> [CODE] Hello i have problem is i have penny auction script and i try to add auction and it show on indexpage assume 05-05-2011 but when the time hit 00.00 so date become to 6 and back to 5 in the morning maybe 12 hour and i try to change var.match round to var math.floor date become to 4 before midnight 2 minute and back to 5 when the time hit midnight again...so if this day is 5 and before midnight it will not become to 4 but when midnight come it will become to 6...so i dont know when item can end then this is code if someone can sort it out function calc_counter_from_time22(diff) { if (diff > 0) { hours=Math.floor(diff / 3600) minutes=Math.floor((diff / 3600 - hours) * 60) seconds=Math.round((((diff / 3600 - hours) * 60) - minutes) * 60) } else { hours = 0; minutes = 0; seconds = 0; } if(diff < 86400){ return twodigit(hours) + ":" + twodigit(minutes) + ":" + twodigit(seconds); } else{ var Tday = Math.floor(diff / (60 * 60 * 24)); var addDay = Tday; var d = new Date(); d.setDate(d.getDate()+addDay); mkMonth=d.getMonth()+1; mkMonth=new String(mkMonth); if(mkMonth.length==1){ mkMonth="0"+mkMonth; } mkDay=d.getDate(); mkDay=new String(mkDay); if(mkDay.length==1){ mkDay="0"+mkDay; } mkYear=d.getFullYear(); return mkDay+"-"+mkMonth+"-"+mkYear; } Hi, Which is the difference between to use "<!-- //-->" inside the script or not? Quote: <script language=JavaScript> <!-- function stopError() { return true; } window.onerror = stopError; // --> </script> Quote: <script language=JavaScript> function stopError() { return true; } window.onerror = stopError; </script> Any advice is welcome!! stickers Hi there, I'm sure someone can help me with this simple fix. I am putting a site together for a friend and I found a Javascript code that I'm using which basically causes an image to enlarge on mouse rollover. The website, which I just started, is: Home 2 What I'm trying to do is get the larger image to appear a little more to the right than it currently does, so it is not right on top of the thumbnails. I hope someone can tell me what code (and where) I need to add to accomplish this. I'm quite new at this so I really need specific instruction. Thanks in advance for your help! Here is the code for the onmouseover routine: Code: <head> <script language="JavaScript"> function showlargeimage(imgshow) {document.getElementById('image').src=imgshow;} function showlargeimage(imgshow) {document.getElementById('image').src=imgshow; document.getElementById('image').style.display='block'; } </script> </head> <body> <TABLE> <TR> <TD> <!--THUMBNAILS--> <img src="thumbnail1.jpg" onmouseover=showlargeimage('image1.jpg')><br> <br> <img src="thumbnail2.jpg" onmouseover=showlargeimage('image2.jpg')><br> <br> <img src="thumbnail3.jpg" onmouseover=showlargeimage('image3.jpg')><br> <br> <img src="thumbnail4.jpg" onmouseover=showlargeimage('image4.jpg')><br> <br> <img src="thumbnail5.jpg" onmouseover=showlargeimage('image5.jpg')><br> <br> </TD> <TD> <!--image SCREEN--> <img src='#' id='image'> <img src='#' id='image' style='display:none'> </TD> </TR> </TABLE> </body> I'm trying to get a drop down box to change the image i've managed to get it working for one but can't seem to get it working when both scripts are on. any help would be much appreciated! http://humza-productions.co.uk/test/ this is the code i'm using, it's for the baseball jacket one but the one that's working live on the website is currently working for the hoodie Code: <script type="text/javascript"> window.onload=function() { bp='images/', //base url of your images imgnum=3, //Number of your images. This should match on your comboboxes options. thumb=document.getElementById('sho1'), //id of your image that will be changing combobox=document.getElementsByName('os1')[0]; // id of your combobox. combobox.onchange=function() { thumb.src=bp+'shop'+this.value+'.png'; } } </script> Ok this is supposed to be a slot machine that works when I click the "Slot" button. If all the images match, then it is supposed to say "Congratulations...". If all the images do not match, then it is supposed to say "Sorry, you lose....". For one thing, I want the images to load after I hit the slot button and not when I refresh the page. Also, I've screwed up somewhere and I think I need another function option but I don't know where to put it or what to do. And last, my if, else statement isn't working. I'm pretty much new to Javascript and I don't know if the way I assigned the images to variables is even correct. Someone please help me. It would greatly appreciated. PHP Code: <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title> Slot Machine</title> <style type = "text/css"> table { width: 45em } th { text-align: left } th { text-align: center } th { text-align: right } div.red { color: red } </style> <script type = "text/javascript"> <!-- var pictures = [ "star", "blueSeven", "berry" ]; var pic1; var pic2; var pic3; pic1 = document.write ( "<img src = \"" + pictures[ Math.floor( Math.random() * 3 ) ] + ".gif\" />" ); pic2 = document.write ( "<img src = \"" + pictures[ Math.floor( Math.random() * 3 ) ] + ".gif\" />" ); pic3 = document.write ( "<img src = \"" + pictures[ Math.floor( Math.random() * 3 ) ] + ".gif\" />" ); function play() { var statusDiv = document.getElementById( "status" ); if ( pic1 = pic2 ) { if ( pic2 = pic3 ) statusDiv.innerHTML = "Congratulations, you win!"; } else statusDiv.innerHTML = "Sorry, you lose. " + "Please try again."; } </script> </head> <body> <form action = ""> <table> <tr><td /><td><input type = "button" value = "Slot" onclick = "play()" /></td></tr> </table> <div id = "status" class = "red"> Click the Slot button to play</div> </form> </body> </html> Hi all, Can some body help me i need a textbox and submit button.when i enter date in text box and click on submit button.Then my chart should display by passing my date(dynamic) through the code. how to design and code. Thanks.. Code: <script type="text/javascript"> var aURL = "http://xmegatop100.com/"; if (aURL == http://xmegatop100.com/) { document.write("<p style="text-align: right;"> <a href="{$list_url}/index.php">1-50</a> | <a href="{$list_url}/index.php?start=51">50-100</a> | <a href="{$list_url}/index.php?start=101">100-150</a> | <a href="{$list_url}/index.php?start=151">150-200</a></p> <br><br> "); } else { document.write("<p style="text-align: right;"> <a href="{$list_url}/index.php?cat={$category_url}&start=1">1-50</a> | <a href="{$list_url}/index.php?cat={$category_url}&start=51">50-100</a> | <a href="{$list_url}/index.php?cat={$category_url}&start=101">100-150</a> | <a href="{$list_url}/index.php?cat={$category_url}&start=151">150-200</a></p> <br><br> "); } </script> What im trying to do is if i have url as http://mysite.com then read1 code , if my site has http://mysite.com/index.php?cat=~~~~ Then reads the else part.. am i doing something wrong? this doesnt work.. |