Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 27th, 2005, 06:28 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default make javascript code more dynamic

        noinf = document.form.noi.value;

            var inf_length2 = document.form.birthday2.value.length

                var do_not_check_full_dob = true;
                var do_not_check_full_dob = false;


            var inf_length3 = document.form.birthday3.value.length

                var do_not_check_full_dob = true;
                var do_not_check_full_dob = false;


            var inf_length4 = document.form.birthday4.value.length

                var do_not_check_full_dob = true;
                var do_not_check_full_dob = false;

I am trying to make my code run as smoothly as possible, is there a way to make this code more dynamic? Put it in a loop or something?


Ayrshire Minis - a Mini E-Community
Reply With Quote
  #2 (permalink)  
Old September 27th, 2005, 11:44 AM
Authorized User
Join Date: Jul 2005
Location: New York, New York, .
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts

Based upon what you wrote, I think you meant to check the dob.
1st: I would use switch
2nd: Write up a function to get the value length
3rd: Conditional operator

function yourFunc(){
noinf = document.form.noi.value;

if noinf != "" {
  var inf_length = getValueLength('birthday'+ noinf);
  do_not_check_full_dob = (inf_length > 0) ?
       ( (inf_length < 8)? true: false) : false;

} // if noinf != ""

 .... your other operations...

} // end yourFunc()


/** get the length */
function getValueLength(controlID){
  if (document.form.controlID) {
    return document.form.controlID.value.length;

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
build switch statement to make dynamic crmpicco Javascript How-To 0 October 27th, 2005 05:44 AM
make javascript code more dynamic crmpicco Javascript How-To 3 October 17th, 2005 05:40 AM
Can JavaScript Make Recommendations? angela18cali Javascript 1 November 16th, 2004 04:24 AM
Can JavaScript make recommendations? angela18cali Javascript How-To 0 November 15th, 2004 07:31 PM

All times are GMT -4. The time now is 02:56 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.