OT: Javascript help?

Bradley Miller bradmiller at dslonramp.com
Tue Sep 3 18:23:10 CDT 2002


At 01:28 PM 9/3/02 -0500, Jason Clinton wrote:
>Have id and status been declared as global variable?

Here's the entire enchilda -- like I said I can't think of how to get the
"id" to refer to my "documents.MyForm.FieldName" properly.  The alert box
just says (literally) "documents.MyForm.FieldName.value" and doesn't give
the actual VALUE of that FieldName field.  (Price is what I'm trying to
fix, so nobody bozos the $, stuff.)  If I change the script to say
"documents.MyForm.FieldName" everywhere instead of the "id" it works great,
but I can't guarantee that each instance will always be called "FieldName".
 I might add 12 more Price fields (Price1,Price2,etc...) and I would want
the script to work with each of those independently.  Does this make sense ?

<script>
<!-- 
// Expects to receive the name or the identifier for a form object (id)

	// and a string (status) indicating what characters are permissible.

	

	function stripBadchs(id,status) {

	
	alert(id + ".value");
	
	
	  var bad = 0

	  for (i = 0; i < id.value.length; i++) {

	    ch = id.value.substring(i, i + 1);

	    if ( status == "letters or numbers" ) { if ( (ch < "a" || "z" < ch) &&
(ch < "A" || "Z" < ch) && (ch < "0" || "9" < ch) ) { bad = 1; } }

	    if ( status == "letters" ) { if ( (ch < "a" || "z" < ch) && (ch < "A"
|| "Z" < ch) ) { bad = 1; } }

	    if ( status == "dollar value" ) { if ((ch == "$") || (ch == ",")) {
bad = 1 } }

	    if ( status == "numbers" ) { if (ch < "0" || "9" < ch) { bad = 1 } }

		if ( bad == 1 ) {	

	      id.value =
id.value.substring(0,i)+id.value.substring(i+1,id.value.length)

	      i=i-1

	      bad = 0

	    }

	  }

	}

// -->

</script>




More information about the Kclug mailing list