namu
03-19-2009, 03:41 AM
prob solvd
|
||||
need help displaying content from array into textareanamu 03-19-2009, 03:41 AM prob solvd Philip M 03-19-2009, 09: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, 10:35 AM prob solvd Philip M 03-19-2009, 10: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, 12:08 PM solvd |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum