JavaScript - Code For Message Of The Day
Hello all,
I'm trying to write a simple script in JS that will show a message for each day of the week. I have searched in your forums and other places but sadly I keep failing. Thank you for helping a newb. Code: <script type="JavaScript"> function showMessage() { var d = new Date(); var day = d.getDay(); // Note: Sunday=0, Monday=1, etc... switch( true ) } case ( day == 6 ) : { document.write("Today is saturday!") } case ( day == 5 ) : { document.write("Today is friday!") } case ( day == 4 ) : { document.write("Today is thursday!") } case ( day == 3 ) : { document.write("Today is wednesday!") } case ( day == 2 ) : { document.write("Today is tuesday!") } case ( day == 1 ) : { document.write("Today is monday!") } case ( day == 0 ) : { document.write("Today is sunday!") } } } </script> Similar TutorialsHi 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. I was wondering if there was an easy way to configure a message box to resemble that of a login form. It would preferably have two text fields for username/password and OK and Cancel buttons as well. I currently have a normal login form on my website designed using PHP but it does not figure into what we need to do now. I'm not sure about going about this and I have tried looking for quite sometime for an example of this but cannot find one.
i have multiple customers in my company and i want to send an SMS to the mobile (cell phone) of the customer that he must pay the renewals fee's durng 2 weeks.. so i send to him an e-mail and at the same time i send for him an SMS message to his phone to ensure that he will read the message that he must pay the fee's. i dont know if there is a module that can make this idea or i must buy a product or register into a website to make this module... thnx alot Hi all new guy on the block here, I've got a website, and I want to add a welcoming message which hovers on a certain part of the page which only loads for the visitor for the first time they login, and won't again(presumably cookies used). And says something like "adjust your settings here.." I don't want it to be an external popup but something that loads on the page in a certain area, defined by me (PX-pixle reference) I think i nutted something out in a bit of PHP, this is what i've got so far PHP Code: <?php if (firstLogin()){ genSpecial(***load jquerie or css etc***); } else{ genRegular(); } ?> can anyone help me figure out how to make this all work and load a box from jquerie or something similar? thanks David Hee guys, I've got a little bit of a problem on my hand. Someone has asked me to help them on a FREE forum host. You have no access to PHP or SQL or anything like that. Just the templates, but even those are really messy! Now on the navagation bar there a PM section (obviously) but the wording they have used is very long and ugly. I was wondering if it would be possible to change the wording whilst still having it show the amount of PM's that you have. If you need anymore information just ask, but I really hope someone can help okay. I am in the process of learning javascript and I've been looking at this code for the longest time ever. So far I got most of it done. but the problem is for example I leave all the required fields empty, it gives me the alert message of the first field and not the alert messages of all the others. What I want to know is how can you go through and check the whole form first before submitting and then when there is any error on any field, shows just one alert message containing all the error messages. code for the form Code: <form action="mailto:hummdedum@felloff.com" method="post" name="form" onSubmit="return isFormValid();"> * First Name: <input type="text" name="FName" id="FName" onblur="checkFName();"/><label id="labelFName"></label><br /> * Last Name: <input type="text" name="LName" id="LName"onblur="checkLName();"/><label id="labelLName"></label><br /> * Password: <input type="password" id="pw" name="Password" onblur="checkpw();" id="pw"/><label id="labelpw"></label><br /> *Re-type Password: <input type="password" name="2Password" id="pw2" onblur="checkpw2();" /><label id="labelpw2"></label><br /> I am a: <br /> <input type="radio" name="status" value="fresh" /> Freshman<br /> <input type="radio" name="status" value="soph" /> Sophomore<br /> <input type="radio" name="status" value="jr" /> Junior<br /> <input type="radio" name="status" value="sr" /> Senior<br /> I am taking classes in the: <br /> <input type="checkbox" name="semester" value="fall" /> fall time<br /> <input type="checkbox" name="semester" value="spring" /> Spring time <br /> My favorite element is: <select name="element" id="element"> <option value="">select one</option> <option value="fire">Fire</option> <option value="earth">Earth</option> <option value="water">Water</option> <option value="air">Air</option> </select><br /> *Birthday: <input type="text" id="BDay" name="Birthday" onblur="checkBDay();"/><label id="labelBDay"></label><br /> *E-Mail: <input type="text" id="email" name="Email" onblur="checkEmail();"/><label id="labelEmail"></label><br /> <input type="submit" value="Submit" /> <input type="reset" value="Clear" /> </form> code for the javascript Code: function isFormValid() {var userF = document.getElementById('FName').value; var userL = document.getElementById('LName').value; var userPW = document.getElementById('pw').value; var userPW2 = document.getElementById('pw2').value; var userBDay = document.getElementById('BDay').value; var userEmail = document.getElementById('email').value; var NameFormat = /^[A-Za-z]{2,12}$/; var PWFormat = /^[A-Za-z0-9{6,12}$]/; if (!NameFormat.test(userF)) { alert("First Name is required and should only have letters. 2-12 letters max"); return false; } if (!NameFormat.test(userL)) { alert("Last Name is required and should only have letters. 2-12 letters max"); return false; } if (!PWFormat.test(userPW)) { alert("Password is required and should only have letters and numbers. 6-12 letters max"); return false; } if (userPW != userPW2) { alert("Passwords do not match."); return false; } } function checkFName() { var userF = document.getElementById('FName').value; var elementF = document.getElementById('labelFName'); var NameFormat = /^[A-Za-z]{2,12}$/; if (!NameFormat.test(userF)) { elementF.innerHTML = "First Name is required and should only have letters. 2-12 letters max"; elementF.style.color = "red"; } else { elementF.innerHTML = ""; elementF.style.color = "green"; } } function checkLName() { var userL = document.getElementById('LName').value; var elementL = document.getElementById('labelLName'); var NameFormat = /^[A-Za-z]{2,12}$/; if (!NameFormat.test(userL)) { elementL.innerHTML = "Last Name is required and should only have letters. 2-12 letters max"; elementL.style.color = "red"; } else { elementL.innerHTML = ""; elementL.style.color = "green"; } } function checkpw() { var userPW = document.getElementById('pw').value; var elementPW = document.getElementById('labelpw'); var PWFormat = /^[A-z0-9]{6,12}$/; if (!PWFormat.test(userPW)) { elementPW.innerHTML = "Password is required and should only have letters and numbers. 6-12 letters max"; elementPW.style.color = "red"; } else { elementPW.innerHTML = "Valid Password"; elementPW.style.color = "green"; } } function checkpw2() { var userPW2 = document.getElementById('pw2').value; var userPW = document.getElementById('pw').value; var elementPW2 = document.getElementById('labelpw2'); if (userPW != userPW2) { elementPW2.innerHTML = "Passwords do not match."; elementPW2.style.color = "red"; } else { elementPW2.innerHTML = "Passwords Match"; elementPW2.style.color = "green"; } } I want to also validate birthday.. and I tried using regular expression with leap years but the expression is too hard for me to think of. so I am gonna try using split() but I dont noe... and for the clear button. since I blur functions, how would I just clear all the blur statements = like a restart of the form and then when the user enters the field the blur function still works? thanks -pumpkin I can't seem to shake this error message. Here is the code I am working with PHP Code: <tr> <td> <img onClick="showUser(1,\''.$time.'\');" src="'.$this->getPhoto($array[0][1]['uid'],'').'" > </td> <td> <img onClick="showUser(2,\''.$time.'\');" src="'.$this->getPhoto($array[0][2]['uid'],'').'" > </td> <td> <img onClick="showUser(3,\''.$time.'\');" src="'.$this->getPhoto($array[0][3]['uid'],'').'" > </td> <td> <img onClick="showUser(4,\''.$time.'\');" src="'.$this->getPhoto($array[0][4]['uid'],'').'" > </td> and the function PHP Code: '.$this->get_javascript_array($this->data,'data').' function showUser(arr, time) { var likes; var comments; switch(time) { case "Day": likes = data['day\'][0][arr][\'likes\']); comments = data[\'day\'][0][arr][\'comments\']); break; case "Week": likes = data[\'week\'][0][arr][\'likes\']); comments = data[\'week\'][0][arr][\'comments\']); break; case "Month": likes = data[\'month\'][0][arr][\'likes\']); comments = data[\'month\'][0][arr][\'comments\']); break; case "Year": likes = data[\'year\'][0][arr][\'likes\']); comments = data[\'year\'][0][arr][\'comments\']); break; } }; </script> '; I keep getting the following error and it's driving me nuts PHP Code: missing ; before statement [Break on this error] likes = data['day'][0][arr]['likes']);n Hello, I was wanting a message to be displayed if it is the visitors first time to the site. It will be a toolbar displayed at the top of the website, with links to FAQ's. Any method of display this is fine. Thanks Can anyone help me with the following error message and correlating script please. I think it's just a simple omission. Any help appreciated. Thanks Microsoft VBScript compilation error '800a0400' Expected statement /shop$db.asp, line 3083 end sub ^ sub ShopWriteHeaderBox (msg) %> <div class="comment_title fontbold"><%=msg%></div> <div class="comment_text"> <div class="blog_review_container" > <% end sub sub ShopWriteFooterBox (yesbr) %> </div> </div> <% if lcase(trim(yesbr)) = "yes" then %> <br /> <% end if end sub Hi, I'm trying to figure out how to make this work and I'm stumped. I wrote this code: <script type=text/javascript> function firstfunction(); { if(document.form1.inputnumbers.value="55"); { document.form1.outputstate.value="this is a number"; } else if { document.form1.inputnumbers.value="never"; } { document.form1.outputstate.value="this is a number"; } else { document.form1.outputstate.value=""; } </script> <form name="form1" method="post"> <input type="text" id="inputnumbers" name="inputnumbers";> <input type="button"; value="Enter"; onclick="firstfunction()"><br><br> <textarea id="outputstate"; name="outputstate"; cols=60; rows=10; style="border:1"; readonly;> I'm trying to doing something really simple but I can't seem to make it work. I'm trying have the textarea display a certain message depending on if the first input box says a certain word or number. So like in the code, if the user types "55" or "never" in the first box, then the second box should say a certain message. Then I used the else statement so that if "55" or "never" is not entered, then the second box says nothing. If you can spot my error or suggest a different way of going about writing the code, it would be very much appreciated. Thank you. hi guys, im not very good with javascript/jquery, i have the following code: Code: <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(window).ready(function() { $("#responsecontainer").load("includes/inc-mess-jail.php", function(response, status, xhr) { }); var refreshId = setInterval(function() { $("#responsecontainer").load('includes/inc-mess-jail.php?randval='+ Math.random()); }, 9000); $.ajaxSetup({ cache: false }); }); </script> it basically updates the div tag: Code: <tr> <td colspan="2"> <div id="responsecontainer" align="center"></div> </td> </tr> i wanted to add an error message to it, that comes up underneath the <div id="responsecontainer" align="center"></div> that says "Error" with an id number next to it, then when your mouse goes over it a box comes out saying "there was a problem retrieving your information. the game will continue trying to resolve this" and then underneath where it says error i would like it to say the number of attempts it has tried to recollect the information. obviously i would only like this error message to come up, when it cannot refresh the information. Any help would be great, even pointing me in the right direction javascript2.js Code: function displayMessage(msg) { // Open a new window var msgWindow = window.open('', 'Message'); // Write message in the new Window msgWindow.document.write(msg); // Raise this window, in case it's not visible msgWindow.focus(); } //Enter total number of questions: var totalquestions=13 var correctchoices=new Array("a","a","b","c","b","c","a","a","b","c","a","b","b"); var correctanswers=new Array("memory locations","_ underscore","x=5+5;","20","Else","lose win","ticker = ticker + 1;","Ticker = ticker + 1;","300.000","Jonathon \b","var","var counter;","var mark = 50, 70"); function gradeit(){ var actualchoices=new Array() var msg1=new Array() var correctanswersno=0 var t=0 var displaycorrectanswers="" for (q=1;q<=totalquestions;q++){ var thequestion=eval("document.Questionform.q"+q) for (c=0;c<thequestion.length;c++){ if (thequestion[c].checked==true) actualchoices[q]=thequestion[c].value } if (actualchoices[q]==correctchoices[q]){ msg1[t]=q+")"+" Correct"; correctanswersno = correctanswersno + 1; t = t + 1; } else { msg1[t]=q+")"+" Incorrect: <br>Correct Answer: "+correctchoices[q]+") "+correctanswers[q]; t = t + 1; } } for (p=0;p<=12;p++){ displaycorrectanswers+="<br>"+msg1[p]; } var msg="Sco "+correctanswersno+"/"+totalquestions+" <br><br>Marks: "+displaycorrectanswers; displayMessage(msg); } Basically on my index page it has a button which when clicked makes use of gradeit(). Currently this then used displayMessage(msg) which opens a new window and displays the message. However, what I want it to do is to open another created html page e.g. answer.html and then for this page to display the message. How do i do this? Hi, I want to pop up message incase of validation failure of form field. If I use document.write("name shold be between 2 to 15 char only") it redirects to new page and gives this message.......... if I use alert than incase or 2 or more validation fail it gives multiple or one by one alert boxes. I want to to displey my message near to field............... Code: function validateForm() { var x=document.forms["regform"]["email_id"].value; var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { alert("Not a valid e-mail address"); return false; } } Hi there, I have this form that validates a few textboxes & a dropdownlist. And when it is not filled in, the border of the textboxes and dropdownlist would turn red, followed by an alert message notifying which field have not been filled in. Else, the border will revert back to black, and the form will be submitted successfully. There's a problem whereby when everything is filled in, the alert message still pops up. Any kind souls to help me? Thanks in advance. Javascript Code: function check(checkForm) { var fields = new Array("Name","Email Address", "Domain Name"); var index = new Array(),k=0; for(var i=0;i<fields.length;i++) { var isFilled = false; var c = document.getElementsByName(fields[i]); for(var j = 0; j < c.length; j++) if(!c[j].value == "") { isFilled = true; c[j].className = "defaultColor"; } else { c[j].className ="changeToRed"; } if(!isFilled) { index[k++] = fields[i]; } } if(k.length!=0) { joinComma = index.join(', '); alert('The field(s) corresponding to '+ joinComma + ' is/are not selected.'); return false; } } HTML Code: *Last Name: <input type="text" id="Text27" name="Last Name" /><br /> <br /> *Email Address: <input type="text" id="Text28" name="Email Address" /> @ <select id="Select5" name="Domain Name"> <option></option> <option>hotmail.com</option> <option>yahoo.com</option> </select> <input id="Submit5" type="submit" value="Submit" onclick="return check(checkForm)"/> im trying to display a random number, but each time a button is pressed that calls the test function, i don't want to random number to be repeated. i know i have to declare 2 variables and a while loop, but i'm stuck as to what to put in the second variable and in the while loop. any advice is appreciated var random = Math.floor(Q * Math.random()); var random2 = ?? function test () { document.write(random); while (random == random2) { document.write(random); } } Hi there, I am trying to add something from a textbox within a prompt message into a listbox. When I press the "Add" button, a prompt message will pop up. I will check if the textbox is empty. If it is empty and I press okay, it will show an alert message stating "Empty insert. Please enter something into the textbox." And if I press cancel, it will show alert message "You have pressed cancel." If it is not empty, and I press okay, it will insert the data into the listbox successfully. If I press cancel, it will show alert message "You have pressed cancel." Below are my codes. Javascript Code: function addOption() { var newItem = prompt("Enter New Item"); if (!newItem == "") { var answer = confirm ("Are you sure you want to add? ") if (answer)//if answer is true { var lstBx = document.getElementById("lstBxEmail"); // Now we need to create a new 'option' tag to add to MyListbox var newOption = document.createElement("option"); newOption.value = newItem; // The value that this option will have newOption.innerHTML = newItem; // The displayed text inside of the <option> tags // Finally, add the new option to the listbox lstBx.appendChild(newOption); //sort items in listbox in alpha order arrTexts = new Array(); for(i=0; i<lstBx.length; i++) { arrTexts[i] = lstBx.options[i].text; } arrTexts.sort(); for(i=0; i<lstBx.length; i++) { lstBx.options[i].text = arrTexts[i]; lstBx.options[i].value = arrTexts[i]; } } else { if(newItem) { alert("Key something to textbox please."); } else alert("Cancel choice."); } } } HTML Code: <center><input id="Submit18" type="submit" value="Add Address" onclick="addOption()"/> <div>Address:</div> <center> <select id="lstBxEmail" name="listBoxEmail" multiple="multiple" style="width: 580px;"> <option>Java</option> <option>PHP</option> <option>Perl</option> <option>Javascript</option> <option>C#</option> <option>Powershell</option> </select> </center> Hi, I am using a slideshow and want to basically have an 'image loading' whilst all the images load before the slideshow. Is there a way to do this? So far I have figured the best way around this is to have a GIF as a background image that says the loading message, and then once the slideshow loads over the top its fine, however im guessing this is'nt the right way to do this. I am using this slideshow set to just loop: http://www.dynamicdrive.com/dynamici...lslideshow.htm I am open to using other similar slideshows if there is one more suited. Thanks Hey guys i am creating a Greasemonkey script that adds an ajax chat to a website. Greasemonkey is an addon for firefox that lets you modify the html code of websites before they are showed to the user. I am in the process of creating a wizz feature that will allow you to send a message to a member and where ever he is on the web his gona receive it. The way it works right now is there's a hidden iframe in every page load and when the player has a message it popups a small window It's working great but the popup is always instantly blocked because firefox has a popup bloker integrated and because it can popup on random websites they don't allow it and there for never gets the message ... Everything else i tryed was blocked by the fact that it opens in the iframe that is invisible. I even tryed doing it the old fashon way with an alert() but same thing you don't see it because it's in the hidden frame. And i tryed adding top.alert() but i get a javascript the "Access Denied" message. The "Access Denied" error in any browser usually means that a script in one window or frame is trying to access another window or frame whose document's domain is different from the document containing the script. I know DHTML AJAX popup would be the only way to give the user the message with out being blocked ... but how can i make it popup out of the iframe into the main frame with out being blocked in anyway ... I am out of ideas ... Hi i have been looking everywhere and cant seem time to find anything matching, what i need is a scheduled message on a website, basically stating days of the week and time and who is live on air. also people maybe on air at 17.30 so i have no idea on how to code this. e.g Monday 15th August 17:45 - On Air Now, Lee Mills so it also refreshes every 1 minute Thank you for your help. |