Newbie help please.....

wxdqz

New Member
I am trying do do what I thought was simple...I have a middle ware app making a list of form fields. The field elements are text and contain numbers only. The numbers in the text fields (what the user enters) are used to detemine the "order of a list". So....If there are 5 form fields on a page, then the text fields would be numbered 1,2,3,4,5. The user has the option of "changing the order" of the products listed, so...I have figured out how to limit the entry to numbers only, along with not allowing the entry of a number larger than the number of text fields. (if there are only 5 fields, then the "max order number" can only be 5, so...
Here is my problem...when a user changes one of the text fields, we ONE other text field on the form will now contain a duplicate value, so we need to "swap" the values. In other words, no text fields can contain the same "order by number". I have tried to loop through the form elements to compare, then switch but it doesn't seem to work?? Here is my code....

formField.value is "passed in to the function"

var y = formField.value
var z = 0
for (x=0; x < document.forms[0].elements.length; x++){
//get the value of the element being inspected
z = document.forms[0].elements[x].value;
//if z is == y then switch the values
if(z >= y){
document.forms[<%=iWhatForm%>].elements[x].value = y;
formField.value = z;
Thanks in advance...
David
 
Back
Top