Web Analytics Made Easy -
StatCounter Entering function data into a text box??? - CodingForum

Announcement

Collapse
No announcement yet.

Entering function data into a text box???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Could be that the script is executing before the form elements have been processed. Post the rest of the script.

    Comment


    • #3
      You are right!

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

      Comment

      Working...
      X