Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member
    Join Date
    Aug 2003
    Posts
    194
    Member #
    2782
    Hi Everyone,
    I am working with an online form management system. I have tried to access Support for help, but I have not got a response from them. Throughout the years, the people at WebDesignForums.net have always been a big help, and I assume someone on this board can help me.

    With that said, here is my issue:
    I am using javascript to pre-populate a form on a field based on another field's value. The form management system does not allow me access the input tag and add the "onkeyup" function. Is there any way I can remotely attribute this function to the field within the javascript code instead of the input tag?

    Here is the script I am using (I am pre-populating an age (ID: AGE) field based on the date of birth (ID: DOB) field someone fills out:
    Code:
    <script type="text/javascript">
    function DOBcalc() {
      var DOBmdy = (document.getElementById('DOB').value).split('/');
      Bdate = new Date(DOBmdy[2],DOBmdy[0]-1,DOBmdy[1]);
      BDateArr = (''+Bdate).split(' ');
      document.getElementById('DOW').value = BDateArr[0];
      Cdate = new Date;
      CDateArr = (''+Cdate).split(" ");
      Age = CDateArr[3] - BDateArr[3];
      document.getElementById('AGE').value = Age;
    }
    </script>
    Let me know if it is possible. Thanks!

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    window.onload = function() {
    document.getElementById('DOB').onblur = DOBcalc;
    |

  4. #3
    Senior Member
    Join Date
    Aug 2003
    Posts
    194
    Member #
    2782
    Quote Originally Posted by smoseley, post: 233416
    window.onload = function() {
    document.getElementById('DOB').onblur = DOBcalc;
    |
    Thanks for the quick response! I'm not too skilled in JS so forgive me if this is an elementary question, but I can add that within the script under the curly bracket but before the closing tag, right?

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Yup!

  6. #5
    Senior Member
    Join Date
    Aug 2003
    Posts
    194
    Member #
    2782
    Thank you for your help.

    It seems like this form creator is quirkier than I would like it to be. It won't let me dynamically populate the field using the code above. My alternative would just be to execute the function once the submit button is hit and just have the field populate that way (the age is more for our reference anyway). How can I execute the function when the form is submitted outside of the submit tag?

  7. #6
    Senior Member
    Join Date
    Aug 2003
    Posts
    194
    Member #
    2782
    I've been going crazy trying to figure out why I couldn't get your suggestion above to work. Then I realized you accidentally put a | at the end instead of a }.

    LOL. Thanks for your help.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:53 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com