Save a drop down list value

Results 1 to 3 of 3

Thread: Save a drop down list value

  1. #1
    alf Guest

    Default Save a drop down list value

    I have an ASP page that posts to itself and performs field validation on the server side before sending the data to the dB. One of the fields is State and it is a drop down select with all the State names. For the other fields I simply set their values="<%=Session("fieldName")%>" so the user does not lose the value they entered if they made a mistake somewhere on the form. How can I do this with the State field??

  2. #2
    Join Date
    Dec 1969

    Default RE: Save a drop down list value

    There are a lot of ways to do this.<BR><BR>(ASP) <BR>If the options are all in a string: you can replace a known"&#060;option value=&#039x&#039&#062;" with &#060;option selected value=&#039x&#039&#062;<BR><BR>If the options are in HTML make a function "IsSelected" that takes the value desired and compares it to the options value and returns "SELECTED" or an empty string.<BR>&#060;option value=&#039x&#039 &#060;%=IsSelected(request("value","x")%&#062; &#062;<BR><BR>(JS) for IE in the onload : selSelectBox.value=&#039x&#039 <BR>[for NN-3/4,opera you can&#039t access selSelectBox.value directly, you will need to use the selected index and options]<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Save a drop down list value

    If you are pushing all your form validations through an MTS Component (Business Object) then just do a Request.querystring on the selectedindex to find the value that was selected. If you use a multiple select drop have to put the Request.querystring in a loop and populate and array with the selectedindex values.
    Last edited by Jay; 04-16-2011 at 01:34 AM.

Posting Permissions

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