[thelist] retaining values in forms while alerting use mistakes

Anthony Baratta anthony at baratta.com
Mon Jul 9 12:43:33 CDT 2007


Nan...

How are you building your select boxes? Is the data coming out of a Database? Is it "Static"?

Either way - you should create a function to build the select box for you. Within that function, test for the post value and set the selected state accordingly.

e.g. pseudo-code...

function buildSelect(sName, arrayOfData, sSelectedValue)
   echo "<select name='" + sName + "' id='" + sName + "'>";
   for each datePoint in arrayOfData
     echo <option value='" + datePoint  + "';
     if sSelectedValue == datePoint then
            echo " selected";
     end if
     echo ">" + datePoint + "</option>";
   next
   echo "</select>"
end function

Or something close to that.

-----Original message-----
From: "Nan Harbison" nan at nanharbison.com
Date: Mon, 09 Jul 2007 10:16:10 -0700
To: thelist at lists.evolt.org
Subject: [thelist] retaining values in forms while alerting use mistakes

> I have googled myself silly, and have tried a bunch of ways to maintain the
> values of checkboxes and drop down boxes when the user makes a mistake. Of
> course, text boxes are easy.





More information about the thelist mailing list