I am posting this to help people and to gain point (hopefully). I am on the abomitable list of the close to being banned for my low points. These are a creditted to my willingness to jump into controversial forums and state my own ideas, and my laziness in posting often or start useful threads. I can not call this a tutorial as it does not teach you haw to program fluently in javascript. I only am stating a useful instance and my date script for people to copy.
How many times have you wanted to state something when someone clicked a button, but you did not want to load a whole 'nother page just to say a sentence or two. Here are a few ways to do it:
If you want to use alerts here is how to go about it:
What would happen if you wanted to include quotation marks in your alert? You could do it like this:Code:<FORM> <INPUT type="button" value="next" onClick='alert("The password is FRED ")'> </FORM>
Sometimes alerts are not the answer since no html can be add to one. This can have many uses:Code:<SCRIPT language="JavaScript"> var message = 'Whatever" you" wanted" to "appear in the alert'; </SCRIPT> <FORM> <INPUT type="button" value="next" onClick='alert(message)'> </FORM>
The above code clears the page and prints whatever you type in the message section! It's like having another html page!Code:<SCRIPT language="JavaScript"> var message = 'Whatever you wanted to appear in the on the page including <H1>html</H1>'; </SCRIPT> <FORM> <INPUT type="button" value="next" onClick='document.write(message)'> </FORM>
I will finish up with one last script. I created it, and the code is not the neatest, but I think it will be of some use. It prints out the current date in the follow ing form:
ie:
Today is: June, 2002
Friday the 7th
Here is the code, paste it where you want the date to be displayed:
Well that raps it up for now. Please do not bash me to bad for the sloppiness of the code. I may post more in the future. I hope you can use these examples. If you are interested in learning javascript, please check out this site. It is the best free tutorial I know about.Code:<SCRIPT language="JavaScript"> <!-- dayname = new Array("Null", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") monthname = new Array ("January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") ending = new Array("st", "nd", "rd", "th") var time = new Date() var timey = time.getYear() var timed = time.getDay() var timem = time.getMonth() var timed = time.getDate() var nof = time.getDay() var nof = nof + 1 if(timey < 1000){ timey += 1900 } if (timed == 1 || timed == 21 || timed == 31){ var ender = ending[0] } else{ if (timed == 2 || timed == 22){ var ender = ending[1] } else{ if (timed == 3 || timed == 23){ var ender = ending[2] } else { var ender = ending[3] } } } document.write("Today is: " + monthname[timem] + ", " + timey + " " + dayname[nof] + " the " + timed + ender) //--> </SCRIPT>
http://www.javascriptmall.com/learn/contents.htm.


). I am on the abomitable list of the close to being banned for my low points. These are a creditted to my willingness to jump into controversial forums and state my own ideas, and my laziness in posting often or start useful threads. I can not call this a tutorial as it does not teach you haw to program fluently in javascript. I only am stating a useful instance and my date script for people to copy.
Reply With Quote
