[Zope] validating a field with records in a database

Sheree Beaudette sheree@psouth.net
Wed, 17 Oct 2001 22:25:23 -0400


I hope someone can help with this. I'm under the gun to get this done...

the concept of what I have to do is...

I have a form with several fields on it.  all of the data, once submitted,
goes into 1 MySQL table called t_Obligors.

1.  the user will enter an id (obl_UniqueID) into an input field

2.  as soon as they enter it I want the data in the field to be verified
that a prior Unique ID does not exist (probably onChange event) by searching
the t_Obligors table (I have a sql query called cldmGetObligorUniqueIDs) at
this point obl_UniqueID is not the primary key and I'm not sure if I want it
to be because the database was not originally set up with this field so it
would be a lot of work to go back and re-populate data.  (I'm also under a
tight deadline)

3.  to do the actual event I was using Javascript (this one would occur on
the onChange event) for my form validation since that's what I know and I
don't have time at this point to learn something new since it needs to be
done very quickly.

4.  if there's a match they get a message saying that ID is already in use
so please enter another

Here was a thought I had been playing with:
below sets an increment, i, and attempts to populate an array for future use
in my Javascript but I cannot get the array to increment, I don't even know
how to refer an array (or whatever it's called) in Zope.

<dtml-call "REQUEST.set('i', 0)"> - sets increment to zero
<dtml-in clsqGetObligorUniqueIDs> - loops through the query and gets all
Unique IDs
<dtml-call "REQUEST.set('listofids.[i]',obl_UniqueID)"> - trying to set the
array with unique IDs
<dtml-call "REQUEST.set('i', i+1)">
</dtml-in>

this was only one thought, I'm open for suggestions...

Thanks!