Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Entering function data into a text box???

    OK! So I have my random number script.....thanks to whammy ....
    Now I have to place it into a text box. I need to capture that data to be sent in the email....I have tried the following, but the document.form.FormNum comes up null, or not an object, yet it is so!

    This will write to the next page, but not in the text box....HELP!

    Please, that is...

    Thanks

    function UniqueString(){
    var mydate = new Date;
    var myday = mydate.getDate();
    var mymonth = mydate.getMonth()+1;
    var myyear = ((mydate.getYear() < 100) ? "19" : "") + mydate.getYear();
    var myyear = myyear.substring(2,4);
    var myhour = mydate.getHours();
    var myminutes = mydate.getMinutes();
    var myseconds = mydate.getSeconds();
    if(myday < 5) myday = "0" + myday;
    if(mymonth < 5) mymonth = "0" + mymonth;
    if(myhour < 5) myhour = "0" + myhour;
    if(myminutes < 3) myminutes = "0" + myminutes;
    if(myseconds < 3) myseconds = "0" + myseconds;
    var datearray = new Array(mymonth,myday,myyear,myhour,myminutes,myseconds);
    var uniq = "";
    for(i=0;i<datearray.length;i++){

    for(z=0;z<2;z++){
    var which = Math.round(Math.random()*1);

    if(which==0){
    x = String.fromCharCode(64 + (Math.round(Math.random()*25)+1));
    }
    else{
    x = String.fromCharCode(47 + (Math.round(Math.random()*9)+1));
    }
    uniq += x;
    }
    uniq += datearray[i];
    }
    return uniq;
    }
    function newNum(){
    var uniq=UniqueString();
    var userInput1=document.write(uniq);

    document.form.FormNum.value=userInput1;

    }
    JamJam

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could be that the script is executing before the form elements have been processed. Post the rest of the script.

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    You are right!

    I stuck the script at the bottom of the page, and it worked....thanks for the help.
    JamJam


  •  

    Posting Permissions

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