If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > edit pages

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-04, 23:19
zobernjik zobernjik is offline
Registered User
 
Join Date: Feb 2004
Location: Australia
Posts: 183
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.
Reply With Quote
  #2 (permalink)  
Old 10-25-04, 23:40
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On