dynamic form

Results 1 to 3 of 3

Thread: dynamic form

  1. #1
    kate Guest

    Default dynamic form

    I am trying to do this stuff for past two days but to no avail... <BR>I am building a dynamic form from db for searching the db when user enetrs some values in the form....I am reading the vlaues right from but when I am trying to put them in my where clause it always show a trailing "AND" after the last value and when I print out the where claues it always print only the field name and value for last form field ....following is my code ....<BR>any ideas what I am doing wrong here <BR><BR><BR>for x=0 to ubound(search_field) <BR> if search_value(x) &#060;&#062; "" then <BR> <BR> search_clause=search_clause&","<BR> search_clause=search_field(x)&"=&#039;"&(trim(sear ch_value(x)))&"&#039; AND "<BR> Response.Write "&#060;HR&#062;" & search_clause & "<BR>Len(search_clause) is " & Len(search_clause) & ", Left size is " & (Len(search_clause)-Len(" AND ")) & "&#060;HR&#062;" <BR> search_clause = Left(search_clause, Len(search_clause) - Len(" AND ")) <BR> strSrchClause = search_clause<BR> <BR> <BR> <BR> end if <BR> next <BR> Response.Write strSrchClause<BR>

  2. #2

    Default RE: dynamic form

    Alter your string creation script - Check WHERE the AND is being put in too many times, and then Add some Logic code e.g. IF THEN etc around it to prevent !

  3. #3
    Join Date
    Dec 1969

    Default Did I *really* write the code THAT way?

    I sure hope not!<BR><BR>Anyway, I just saw your MAJOR MAJOR mistake! You put the "chop" line in the WRONG PLACE!!!<BR><BR>Here, do *THIS*:<BR><BR>&#060;%<BR>for x=0 to ubound(search_field) <BR>&nbsp; &nbsp; if search_value(x) &#060;&#062; "" then <BR>&nbsp; &nbsp; &nbsp; &nbsp; search_clause=search_clause & "," & search_field(x) _<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; & "=&#039;" &(trim(search_value(x))) & "&#039; AND "<BR>&nbsp; &nbsp; end if <BR>next <BR>strSrchClause = Left(search_clause, Len(search_clause) - Len(" AND ")) <BR>Response.Write strSrchClause<BR>...<BR>%&#062;<BR><BR>Sigh. You only want to chop off the *LAST* AND that was put on the string! The way you wrote it, it was chopping off *EVERY* single one, just after you put them on! <BR><BR>Again, if you&#039;d looked carefully at the output of those Response.Write lines, you *should* have seen that that was what was happening.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts