Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript/CF Dynamic Form Validation

Status
Not open for further replies.

modfather

MIS
Feb 15, 2000
75
0
0
US
Hoping someone can help me out... I have a SQL Server table with three fields: PartNum, Qty, and Increment. The first two fields are obvious, but the third (Increment) signifies that this part must be ordered in multiples of (Increment). So:

PartNum: 12345, Qty: 30, Increment: 50
PartNum: 23456, Qty: 100, Increment: 100
PartNum: 34567, Qty: 10, Increment: 0

The first record should fail a data validation check, as that part needs to be ordered in increments of 50. Records 2 & 3 are fine (Increment of 0 means no requirement).

The problem I have is I dynamically create form elements (text boxes) for my Qty and Increment (Qty is visible, Increment is hidden). The Qty text boxes are created in a <CFLOOP> tag and are named &quot;Qty1&quot;, &quot;Qty2&quot;, etc. The same is true with my &quot;Increment1&quot; hidden text boxes. I populate the value of the Increments with the appropriate value from my table, but I don't know how to perform the dynamic data validation using Javascript. Here's my form elements:

<input name=&quot;qty#currentrow#&quot; type=&quot;text&quot; class=&quot;font003&quot; value=&quot;0&quot; size=&quot;3&quot; onChange=&quot;myTest(this)&quot;>
<input name=&quot;increment#currentrow#&quot; type=&quot;hidden&quot; value=&quot;#increments#&quot;>

The problem I have is: Rather than passing &quot;this&quot; (the Qty text box), how can I pass the appropriate Qty field and it's corresponding Increment field? Or how can I pass the entire form and pick out just the fields I need?

I'm a bit lost, obviously... :) Thanks very much to anyone who can help...

Thanks!
Steve
 
You can pass the javascript function the #currentrow#. Inside the function you can use

document.Form.elements['qty' + currentRow].value and
document.Form.elements['increment' + currentRow].value

I hope that helps.
 
How about a dropdown box with a reasonable number of choices for the multiples of the case value? That way there's no question that the quantity is correct. Present a text box as usual for those parts that have no quantity restriction.

Phil Hegedusich
Senior Web Developer
IIMAK
-----------
Boy howdy, my Liberal Studies degree really prepared me for this....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top