Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2001

    Post Javascript tidbits

    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:
    <INPUT type="button" value="next" onClick='alert("The password is FRED ")'>
    What would happen if you wanted to include quotation marks in your alert? You could do it like this:

    <SCRIPT language="JavaScript">
    var message = 'Whatever" you" wanted" to "appear in the alert';
    <INPUT type="button" value="next" onClick='alert(message)'>
    Sometimes alerts are not the answer since no html can be add to one. This can have many uses:

    <SCRIPT language="JavaScript">
    var message = 'Whatever you wanted to appear in the on the page including <H1>html</H1>';
    <INPUT type="button" value="next" onClick='document.write(message)'>
    The above code clears the page and prints whatever you type in the message section! It's like having another html page!

    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:
    Today is: June, 2002
    Friday the 7th

    Here is the code, paste it where you want the date to be displayed:

    <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]
              if (timed == 2 || timed == 22){
              var ender = ending[1]
                  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)
    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.

  2. #2
    Junior Member
    Join Date
    Jun 2002
    Bumping UP, I couldn't see a JS tutorial go down in flames like this

  3. #3
    Senior Member
    Join Date
    Nov 2001
    You did a lot of fux0ring about when you were trying to get the year. Maybe this might help.
    <script language="JavaScript">
    var time = new Date();
    var year = time.getFullYear();
    Just a thought.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.