Results 1 to 2 of 2

Thread: edit pages

  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Unanswered: edit pages

    Once again I have trouble keeping values appear selected when page edited since there are pages with a different coding stye and the code I use for all the other combos doesn't quite apply here.

    So this is the code that populates the combo.


    szCommissionable = ""
    if myRec.EOF = false then
    szCommissionable = myRec("Commissionable ")
    end if

    call myRec.Open("SELECT Value, Description FROM Trim.dbo.viewZYesNo", myCon)
    do while not myRec.EOF
    szOptions5 = szOptions5 & "<OPTION value=""" & CStr(myRec("Description")) & """>" & _
    myRec("Description") & "</OPTION>" & Chr(10)
    myRec.MoveNext
    loop
    call myRec.Close
    call WriteTableLine("Commissionable:", "<SELECT id=Commissionable name=Commissionable>" & _
    "<OPTION value=""""> </OPTION>" & _
    szOptions5 & "</SELECT>")


    Could somebody help me customize this code so I can have combo values appear selected when edited.

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    okie,.. I'm going to try and do this in a way so you learn the idea and can do it youself from now on.
    Code:
    szCommissionable = ""
    if not(myRec.EOF) then
      szCommissionable = myRec("Commissionable ")
    end if
    
    call myRec.Open("SELECT Value, Description FROM Trim.dbo.viewZYesNo", myCon)
    do while not myRec.EOF
      'somewhere in here you need to decide what to select
      szOptions5 = szOptions5 & "<OPTION value=""" & CStr(myRec("Description")) & """>" & _
        myRec("Description") & "</OPTION>" & Chr(10)
      myRec.MoveNext
    loop
    call myRec.Close 
    call WriteTableLine("Commissionable:", "<SELECT id=Commissionable name=Commissionable>" & _
    "<OPTION value=""""> </OPTION>" & _
    szOptions5 & "</SELECT>")
    See the bold line above. In that loop you need to decide what option you want selected. Use a stand if statement and if it is the right one write out the selected attribute... in psuedo code something like....
    Code:
    do while not myRec.EOF
      if thisoption = selectedOption  then
        szOptions5 = szOptions5 & "<OPTION selected value=""" & CStr(myRec("Description")) & """>" & _
        myRec("Description") & "</OPTION>" & Chr(10)
      else
        szOptions5 = szOptions5 & "<OPTION value=""" & CStr(myRec("Description")) & """>" & _
        myRec("Description") & "</OPTION>" & Chr(10)
      end if
      myRec.MoveNext
    loop

Posting Permissions

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