• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Javascript noob question

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I grabbed a script from http://www.quirksmode.org/js/datecheck.html
It's based on dropdowns. I want it to check text boxes instead.

How would I change
var day = parseInt(x[name+"_DD"].options[x[name+"_day"].selectedIndex].value);
in order to do this?
 
Author
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have three text boxes, then they would be parsed as follows.

var day = parseInt( document.getElementById( "day").value);
var month = parseInt( document.getElementById( "month").value);
var year = parseInt( document.getElementById( "year").value);

The only field where you will have a problem is month because month is displayed as Jan, Feb, etc, but the values are 1, 2, 3. So you will have to create a lookup table.

Christian
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Luzietti:
I grabbed a script from http://www.quirksmode.org/js/datecheck.html
It's based on dropdowns. I want it to check text boxes instead.

How would I change
var day = parseInt(x[name+"_DD"].options[x[name+"_day"].selectedIndex].value);
in order to do this?



Do you want read values from text box? If yes:

var day = parseInt(document.formname.textboxname.value);

replace formname and textboxname with your form and text box names
 
Marc Luzietti
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shoulda mentioned, I can't do a getByElementID (or Name for that matter). I have to check several different pages, and I cannot set the ID/Name (thanks netui ). Also, on one of the pages, there will be multiple sets of dates, so I'll have to write a loop.

I could use Prototype to getByClassName I think, but this would still cause me trouble on the page with the multiple dates.



I'm really going beyond my skills at this point, so I'm really unsure of how to procede . . . but that's how we grow.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic