Ok...so weird question for you....
Date: 10/12/07
(Javascript Community) Keywords: asp, java
Ok, we've got a form where people put in their first name, last name, email address, and a five digit number. On the confirmation page, we want to return to them: the first initial of their first name and full last name and then the first initial of their first name, first initial of their last name, and the five digits they put in.
For example, if I entered:
First Name: Brittany
Last Name: Jackson
5 Digits: 12345
I would want returned:
bjackson
bj12345
We are using Javascript for it, and where it previously worked, it suddenly stopped working.
On the form page, the javascript we have in the header is:
//
function verify(form) {
var errors='';
if ((document.form.first.value == "") || (document.form.last.value == ""))
errors+="Please enter your first and last name.\n";
if (errors){
alert(errors)
return false;}
fa = document.form.first.value.charAt(0);
la = document.form.last.value.charAt(0)
var len;
var aryText = new Array()
var hyp = "";
if (document.form.last.value.indexOf ('-') != -1) {
len = document.form.last.value.indexOf('-')
for (var i = 0; i < len) i++; {
aryText[i] = document.form.last.value.charAt(i);
hyp = hyp + aryText[i];
}
document.form.username.value = fa.toLowerCase() + hyp.toLowerCase();
}
else if (document.form.last.value.indexOf (' ') != -1) {
len = document.form.last.value.indexOf(' ')
for (var i = 0; i < len) i++; {
aryText[i] = document.form.last.value.charAt(i);
hyp = hyp + aryText[i];
}
document.form.username.value = fa.toLowerCase() + hyp.toLowerCase();
}
else{
document.form.username.value = fa.toLowerCase() + document.form.last.value.toLowerCase();
}
document.form.code.value = fa.toLowerCase() + la.toLowerCase() + document.form.numbers.value;
return true;
}
//
The words after form relate to the fields in the form.
And then in the body, under the start of the form class we have (obviously these would have the start and end tags (<>):
form class="forms" name="forms" action="oursite.asp" method="post"
input type="hidden" name="code"
onchange="javascript:this.value=this.value.toLowerCase();" /
input type="hidden" name="username"
onchange="javascript:this.value=this.value.toLowerCase();" /
On our confirmation page/asp page we have:
//
Name |
Username* |
E-mail Address* |
Code |
---|
<% Response.Write(first) Response.Write(" ") Response.Write(last) %> |
<% Response.Write(username) %> |
<% Response.Write(username) %>@oursite.org |
<% Response.Write(code) %> |