...

View Full Version : Entering function data into a text box???



iamjamtart
06-21-2002, 08:17 PM
OK! So I have my random number script.....thanks to whammy ....:thumbsup:
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;

}

x_goose_x
06-21-2002, 09:50 PM
Could be that the script is executing before the form elements have been processed. Post the rest of the script.

iamjamtart
06-22-2002, 03:46 AM
I stuck the script at the bottom of the page, and it worked....thanks for the help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum