dmurray
10-06-2002, 06:49 AM
I have a form within a table that is assigned to a JavaScript variable. This variable is used to fill a <div></div> upon a mouseover event. Because there are other mouseover events on the page that use the same space, I need to restore the values to the form in the event of an accidental overwrite of the form.
The values for the text elements of the form are saved (storeForm() below) to an arrray following an onchange event from any of the text elements (maybe not very efficient but I was confused enough already). The initial and subsequent mouseover events that trigger the form use this arrray (updateForm() below).
Everything works fine in IE6. However, NS 7.0 and Mozilla 1.01 both fail to update the array. As indicated in the comments, I am able to see ...elements [i].attributes['value'].name but not the value when I step through storeForm().
I have attached the code I am working on just in case it may help. I would very much appreciate any push in the right direction.
<script language "JavaScript" type="text/javascript">
// Initialize array if it doesn't already exist
if (!document.forms[0]) {// Tested and ok
var formValue = new Array(18);
for (i=0; i<formValue.length; i++) {
formValue[i] = "1" // Using 1 as a marker
}}
// onchange event, store input text element values in array
// Works as expected on IE6
// Mozilla 1.01 and Netscape 7.0 fail to update the formValue array
// formValue.length is OK
// The function will return the values for all element attributes except ...attribute['value'].value
// ...attribute['value'].name works OK
function storeForm() {
for (i=0; i<formValue.length; i++) {
if (document.forms[0].elements[i].attributes['type'].value == 'text'){
formValue[i] = document.forms[0].elements [i].attributes['value'].value; // Assign current text value to array element
// I think this is where it fails
}}}
// Assign values to the input text boxes from the formValue array
// Works in IE6. The formValue array is not updated so it's not known if this workds in NS7.0 or Mozilla 1.01
// The default value from section.clientReg is displayed before the field is updated by the formValue array
function updateForm(){
thisform = document.forms[0];
for (i=0; i<thisform.length; i++) {
if (thisform.elements[i].attributes['type'].value == 'text'){
thisform.elements[i].setAttribute('value',formValue[i]);
</script>
The values for the text elements of the form are saved (storeForm() below) to an arrray following an onchange event from any of the text elements (maybe not very efficient but I was confused enough already). The initial and subsequent mouseover events that trigger the form use this arrray (updateForm() below).
Everything works fine in IE6. However, NS 7.0 and Mozilla 1.01 both fail to update the array. As indicated in the comments, I am able to see ...elements [i].attributes['value'].name but not the value when I step through storeForm().
I have attached the code I am working on just in case it may help. I would very much appreciate any push in the right direction.
<script language "JavaScript" type="text/javascript">
// Initialize array if it doesn't already exist
if (!document.forms[0]) {// Tested and ok
var formValue = new Array(18);
for (i=0; i<formValue.length; i++) {
formValue[i] = "1" // Using 1 as a marker
}}
// onchange event, store input text element values in array
// Works as expected on IE6
// Mozilla 1.01 and Netscape 7.0 fail to update the formValue array
// formValue.length is OK
// The function will return the values for all element attributes except ...attribute['value'].value
// ...attribute['value'].name works OK
function storeForm() {
for (i=0; i<formValue.length; i++) {
if (document.forms[0].elements[i].attributes['type'].value == 'text'){
formValue[i] = document.forms[0].elements [i].attributes['value'].value; // Assign current text value to array element
// I think this is where it fails
}}}
// Assign values to the input text boxes from the formValue array
// Works in IE6. The formValue array is not updated so it's not known if this workds in NS7.0 or Mozilla 1.01
// The default value from section.clientReg is displayed before the field is updated by the formValue array
function updateForm(){
thisform = document.forms[0];
for (i=0; i<thisform.length; i++) {
if (thisform.elements[i].attributes['type'].value == 'text'){
thisform.elements[i].setAttribute('value',formValue[i]);
</script>