...

View Full Version : need help displaying content from array into textarea



namu
03-19-2009, 04:41 AM
prob solvd

Philip M
03-19-2009, 10:09 AM
I do not undersatnd why your code is so complicated. I suggest you rework it like this:-



<script type = "text/javascript">

var results = new Array();
results[0] = document.registerform.studentname.value;
results[1] = document.registerform.studentphone.value;
results[2] = document.registerform.mfgender.value;
var string = results.join("\n")
document.getElementById("txtarea").value = string;

</script>

OR

string = "Welcome " + results[0];
string = string + "\nName: " + results[0];
string = string + "\nPhone: " + results[1];
string = string + "\nGender: " + results[2];
document.getElementById("txtarea").value = string;

</script>

Validation such as
if (document.registerform.studentname.value == "") {
is barely worthy of the name as a single character or even a space or a ? will return true.
Likewise
if (document.registerform.studentphone.value == "")
does not require numbers.

To be candid, I think this assignment wants a total make-over.


“If you only do what you know you can do - then you never do very much.” - Tom Krause

namu
03-19-2009, 11:35 AM
prob solvd

Philip M
03-19-2009, 11:54 AM
"I do not need the insert and show functions anymore?" Well, no.


You must place the code within a function, and call the function in your submit. But before that you need to call another function to validate the input as I mentioned.

To be candid I think you are trying to walk before you can crawl. As I say, I suggest that you start over, using the code I have given you.




function yourName () {
var results = new Array();
results[0] = document.registerform.studentname.value;
results[1] = document.registerform.studentphone.value;
results[2] = document.registerform.mfgender.value;
var string = results.join("\n")
document.getElementById("txtarea").value = string;
}

</script>

<input type="submit" value="Submit" name="submitform" " onclick="yourName()"/>

namu
03-19-2009, 01:08 PM
solvd



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum