jturkington
asked on
Dynamic Max Length Setup
I have 15 odd form fields that i need to setup their maxlengths that are taken from a SQL table but i am having problems trying to figure out how to associate each database max length value with each form field !?
For Example...
Table
jobboardid fieldidfk maxlength
1 1 100
2 1 75
3 2 75
4 2 50
select fieldfk,min(maxlength)
from table
group by fieldfk
Output
fieldfk min(maxlength)
1 75
2 50
Form Field
<input name="name" value="#FORM.name#" type="text" maxlength=" ??????????" />
What would be the best way to set this up for the 15 form fields, maybe using cfif's compares ??
Cheers
JT
For Example...
Table
jobboardid fieldidfk maxlength
1 1 100
2 1 75
3 2 75
4 2 50
select fieldfk,min(maxlength)
from table
group by fieldfk
Output
fieldfk min(maxlength)
1 75
2 50
Form Field
<input name="name" value="#FORM.name#" type="text" maxlength=" ??????????" />
What would be the best way to set this up for the 15 form fields, maybe using cfif's compares ??
Cheers
JT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This may be better to use..
SELECT COUNT(field1) AS FieldCountOne, COUNT(field2) AS FieldCountTwo, COUNT(field3) AS FieldCountThree
FROM YourTable
ASKER
trailblazzyr55 i dont have individual columns for each form field they are all in the column fieldidfk
errrr. read the question wrong ;^)
pinaldave's should work :o)
pinaldave's should work :o)
ASKER
pinaldave i have a three of four textarea fields how do i get around this ?!?
Hi jturkington,
I did not understand what does it mean by three of four textarea
Regards,
---Pinal
I did not understand what does it mean by three of four textarea
Regards,
---Pinal
Hi jturkington,
if you mean to say that there three textarea the maxlength will not work. you need some javascript validation for that. or serverside validation(which only works with submit)
Regards,
---Pinal
if you mean to say that there three textarea the maxlength will not work. you need some javascript validation for that. or serverside validation(which only works with submit)
Regards,
---Pinal
ASKER
ahh i see pinaldave, looks like i have to manually enter the max lengths as and when they change for each form field !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is there no way to setup 15 variables at the start of the form
eg
Field1maxlength = query.maxlength1
Field2maxlength = query.maxlength2
etc..
and use the variables on the form to set max length and server side validation ??
eg
Field1maxlength = query.maxlength1
Field2maxlength = query.maxlength2
etc..
and use the variables on the form to set max length and server side validation ??
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT MAX(field1) AS FieldCountOne, MAX(field2) AS FieldCountTwo, MAX(field3) AS FieldCountThree
FROM YourTable
<input name="name" value="#FORM.name#" type="text" maxlength="#FieldCountOne#
>>What would be the best way to set this up for the 15 form fields, maybe using cfif's compares ?? not sure what yo mean....
I would prefer <cfscript> less clutter, faster?