Getting any field value

This javascript will return the value from any type of field that has one, i.e radio, checkbox, text etc, I found it to be useful when i'm trying to get multiple field values in javascript.
function setField(fieldName, fieldValue) {
	var count=0;
	switch (eval(fieldName).type) {
		case "hidden" :
			break;
		case "text" :			
			eval(fieldName).value=fieldValue;
			break;
		case "textarea" :
			eval(fieldName).value=fieldValue;
			break;
		case "select-one" :
			for(count=0;count<eval(fieldName).length;count++) {	
				if(eval(fieldName)[count].value=="") {					
					if (eval(fieldName)[count].text==fieldValue) {						
						eval(fieldName)[count].selected=true;						
					}
				} else {
					if (eval(fieldName)[count].value==fieldValue) {
						eval(fieldName)[count].selected=true;						
					}
				}
			}
			break;
		case "radio" :
			if (eval(fieldName).value==fieldValue) eval(fieldName).checked=true;
			break;
		case "checkbox" :
			if (eval(fieldName).value==fieldValue) eval(fieldName).checked=true;
			break;
		default : 
			switch (eval(fieldName)[0].type) {
				case "radio" :
					for (count=0;count$lt;eval(fieldName).length;count++) {
						if (eval(fieldName)[count].value==fieldValue) eval(fieldName)[count].checked=true;
					}
					break;
				case "checkbox" :
					tempArray=fieldValue.split("+");
					for(count=0;count<eval(tempArray).length;count++) {
						for (count1=0;count1<eval(fieldName).length;count1++) {
							if (eval(fieldName)[count1].value==tempArray[count]) eval(fieldName)[count1].checked=true;
						}						
					}
					break;
				default :
					eval(fieldName).value=tempArray[1];
			}
	}

}
This was first published in March 2001

Dig deeper on Domino Resources - Part 6

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close