One problem, similar to before, but different!
Date: 10/26/07
(Web Development) Keywords: asp, java, google
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. Thanks to all of your wonderful suggestions and help, I now have it working in Internet Explorer, Opera, and Safari, but it won't work in Netscape or Firefox and I'm not sure why. I have searched and googled it, but haven't come up with an answer.
On the form page, the javascript we have in the header is (with the script type="text/javascript" in the appropriate < >'s, of course:
//script type="text/javascript"
function verify(forms) {
var errors='';
if ((document.forms.first.value == "") || (document.forms.last.value == ""))
errors+="Please enter your first and last name.\n";
if (errors){
alert(errors)
return false;}
fa = document.forms.first.value.charAt(0);
la = document.forms.last.value.charAt(0)
var len;
var aryText = new Array()
var hyp = "";
if (document.forms.last.value.indexOf ('-') != -1) {
len = document.forms.last.value.indexOf('-')
for (var i = 0; i < len) i++; {
aryText[i] = document.forms.last.value.charAt[i];
hyp = hyp + aryText[i];
}
document.forms.username.value = fa.toLowerCase() + hyp.toLowerCase();
}
else if (document.forms.last.value.indexOf (' ') != -1) {
len = document.forms.last.value.indexOf(' ')
for (var i = 0; i < len) i++; {
aryText[i] = document.forms.last.value.charAt[i];
hyp = hyp + aryText[i];
}
document.forms.username.value = fa.toLowerCase() + hyp.toLowerCase();
}
else{
document.forms.username.value = fa.toLowerCase() + document.forms.last.value.toLowerCase();
}
document.forms.code.value = fa.toLowerCase() + la.toLowerCase() + document.forms.ssn.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="apply.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) %> |