[Javascript] Text Field Arrays

Jay Lepore admin at myinternethandyman.com
Wed May 2 08:06:15 CDT 2001


Thanks everyone.

I figured it out this morning.  When it comes time to assign the elements, a
simple assignment of
elem.value did the trick.

So the code ended up looking like this:

// script side

<script language='JavaScript'>
function nochanging(elem,elementNum){
var changeto;

switch(elementNum)
        {
        case 0:
		changeto="Home Top Left";
		break
        case 1:
		changeto="Home Top Right";
		break
        case 2:
		changeto="Property List Top Left";
		break
        case 3:
		changeto="Property List Top Right";
		break
        case 4:
		changeto="Sale Sheet Top Left";
		break
        case 5:
		changeto="Sale Sheet Top Right";
		break
        }

elem.value=changeto;
}
</script>

// THE FORM

<form name='configurator'>
    <input type='text' name='other fields' size='15' maxlength='30'>";
   <input type='text' name='files_description[0]' size='18' maxlength='30'
onBlur='return nochanging(this, 0)'>";
    <input type='text' name='files_description[1]' size='18' maxlength='30'
onBlur='return nochanging(this, 1)'>";
    <input type='text' name='files_description[2]' size='18' maxlength='30'
onBlur='return nochanging(this, 2)'>";
    <input type='text' name='files_description[3]' size='18' maxlength='30'
onBlur='return nochanging(this, 3)'>";
    <input type='text' name='files_description[4]' size='18' maxlength='30'
onBlur='return nochanging(this, 4)'>";
    <input type='text' name='files_description[5]' size='18' maxlength='30'
onBlur='return nochanging(this, 5)'>";
</form>


FYI:  The 0,1,2,3 values of the text fields allowed me set up an earlier
function that generated a certain number of text fields based on my function
call i.e., numFields(5) would loop through and create 5 text fields, put
them an an array which could be used on the server side.

Thanks everyone for your efforts





More information about the Javascript mailing list