code in ASP/Javascript to ASP/VBscript

I have a page in ASP/JavaScript. I am moving it to ASP/VB script. I need a little help with this part of the code:

I need to show a 'region' based on the value of a field in the recordset.  (Using DW) . recordset name is 'rs_qnrsent', the field name is 'isaccepted'

 If  qnrsent.isaccepted = 0
                    Sent
If qnrsent.isaccepted= 3
                    In progress
If qnrsent.isaccepted= 2
                    Awaiting approval
If qnrsent.isaccepted= 1
                    Accepted
LVL 1
AleksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Try this:

Dim isAccepted ; isAccepted = CInt ( qnrsen("isaccepted") ) 
Dim status 

select case isAccepted 
    case 0: 
         status = "Sent" 
         break 
   case 3:
         status = "in progress" 
         break 
   case 2:
         status = "awaiting approval" 
         break 
   case 1:
         status = "accepted" 
         break 
End select

Response.Write status

Open in new window

0
AleksAuthor Commented:
I get an error:

Microsoft VBScript compilation  error '800a0401'

Expected end of statement

/bluedot/Intranet/inbox/outboxall.asp, line 49
Dim isAccepted ; isAccepted = CInt ( qnrsen("isaccepted") )
0
AleksAuthor Commented:
I changed the names to correspond to my actual records:

Dim IsAccepted ; IsAccepted = CInt ( rs_outboxall("IsAccepted") )
Dim qnrstatus

select case IsAccepted
    case 0:
         qnrstatus = "Sent"
         break
   case 3:
         qnrstatus = "in progress"
         break
   case 2:
         qnrstatus = "awaiting approval"
         break
   case 1:
         qnrstatus = "accepted"
         break
End select

I get the error:

Microsoft VBScript compilation  error '800a0401'

Expected end of statement

/bluedot/Intranet/inbox/outboxall.asp, line 49
Dim IsAccepted ; IsAccepted = CInt ( rs_outboxall("IsAccepted") )
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
That should be a colon, not a semicolon on line 49
0
AleksAuthor Commented:
They all display 'sent' even though the value is 2 or 3. Here is the final code:

Dim IsAccepted : IsAccepted = CInt ( rs_outboxall("IsAccepted") )
Dim qnrstatus

select case IsAccepted
    case 0:
         qnrstatus = "Sent"
     
   case 3:
         qnrstatus = "in progress"
       
   case 2:
         qnrstatus = "awaiting approval"
       
   case 1:
         qnrstatus = "accepted"
       
End select
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
ok let's try using string values instead, they work better in scenarios like this:

Dim IsAccepted : IsAccepted = CStr( rs_outboxall("IsAccepted") ) 
Dim qnrstatus 

select case IsAccepted 
    case "0": 
         qnrstatus = "Sent" 
      
   case "3":
         qnrstatus = "in progress" 
        
   case "2":
         qnrstatus = "awaiting approval" 
       
   case "1":
         qnrstatus = "accepted" 
        
End select

Open in new window

0
AleksAuthor Commented:
no luck. Same .. all say 'sent'
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
it may help to see the entire page worth of code, as I'm guessing the problem may lie elsewhere
0
AleksAuthor Commented:
I am displaying it inside a repeated region.  

as:  <%Response.Write (qnrstatus) %>

This is the code for the repeated region:

----

  <%
While ((Repeat1__numRows <> 0) AND (NOT rs_outboxall.EOF))
%>
  <tr class="gradeX">
    <td><%Response.Write (qnrstatus) %>
-      <%=(rs_outboxall.Fields.Item("IsAccepted").Value)%></td>
    <td><a href="../Qnr/QnrPreview.asp?QnrUserid=<%=(rs_outboxall.Fields.Item("UserId").Value)%>&Qnrmailedid=<%=(rs_outboxall.Fields.Item("Id").Value)%>&Qnrtype=inbox&qnr=1" class="btn btn-white btn-sm"> <i class="fa fa-folder"></i> View </a>&nbsp;<a href="SPDeleteQnr.asp?QnrId=<%=(rs_outboxall.Fields.Item("Id").Value)%>" class="btn btn-white btn-sm" onClick="GP_popupConfirmMsg('Please confirm you wish to delete the Questionnaire.');return document.MM_returnValue"> <i class="fa fa-trash-o"></i> Delete </a>&nbsp;<a href="Resendqnremail.asp?QnrId=<%=(rs_outboxall.Fields.Item("id").Value)%>" class="btn btn-white btn-sm"> <i class="fa fa-envelope"></i> email </a></td>
    <td><%= DoDateTime((rs_outboxall.Fields.Item("SentOn").Value), 2, 9225) %></td>
    <td><span class="bodytext"><%=(rs_outboxall.Fields.Item("SentTo").Value)%>&nbsp;&nbsp;<%=(rs_outboxall.Fields.Item("firstnm").Value)%>&nbsp;<%=(rs_outboxall.Fields.Item("lastnm").Value)%></span></td>
    <td><%= DoDateTime((rs_outboxall.Fields.Item("AcceptedOn").Value), 2, 9225) %></td>
    <td><%=(rs_outboxall.Fields.Item("SenderEmail").Value)%></td>
    <td class="center">
     
      XX
    </td>
  </tr>
  <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rs_outboxall.MoveNext()
Wend
%>

----
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
ok you need to call the code each time otherwise it'll be the same value. make the code I gave you a function and call it in your loop:

<% 
While ((Repeat1__numRows <> 0) AND (NOT rs_outboxall.EOF)) 
%>
  <tr class="gradeX">
    <td><%Response.Write getStatus( rs_outboxall("IsAccepted") ) %>
-      <%=(rs_outboxall.Fields.Item("IsAccepted").Value)%></td>
    <td><a href="../Qnr/QnrPreview.asp?QnrUserid=<%=(rs_outboxall.Fields.Item("UserId").Value)%>&Qnrmailedid=<%=(rs_outboxall.Fields.Item("Id").Value)%>&Qnrtype=inbox&qnr=1" class="btn btn-white btn-sm"> <i class="fa fa-folder"></i> View </a>&nbsp;<a href="SPDeleteQnr.asp?QnrId=<%=(rs_outboxall.Fields.Item("Id").Value)%>" class="btn btn-white btn-sm" onClick="GP_popupConfirmMsg('Please confirm you wish to delete the Questionnaire.');return document.MM_returnValue"> <i class="fa fa-trash-o"></i> Delete </a>&nbsp;<a href="Resendqnremail.asp?QnrId=<%=(rs_outboxall.Fields.Item("id").Value)%>" class="btn btn-white btn-sm"> <i class="fa fa-envelope"></i> email </a></td>
    <td><%= DoDateTime((rs_outboxall.Fields.Item("SentOn").Value), 2, 9225) %></td>
    <td><span class="bodytext"><%=(rs_outboxall.Fields.Item("SentTo").Value)%>&nbsp;&nbsp;<%=(rs_outboxall.Fields.Item("firstnm").Value)%>&nbsp;<%=(rs_outboxall.Fields.Item("lastnm").Value)%></span></td>
    <td><%= DoDateTime((rs_outboxall.Fields.Item("AcceptedOn").Value), 2, 9225) %></td>
    <td><%=(rs_outboxall.Fields.Item("SenderEmail").Value)%></td>
    <td class="center">
      
      XX
    </td>
  </tr>
  <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rs_outboxall.MoveNext()
Wend

function getStatus( valToCheck )
Dim qnrstatus 

select case valToCheck
    case "0": 
         qnrstatus = "Sent" 
      
   case "3":
         qnrstatus = "in progress" 
        
   case "2":
         qnrstatus = "awaiting approval" 
       
   case "1":
         qnrstatus = "accepted" 
        
End select

getStatus = qnrstatus

end function
%>

Open in new window

0
AleksAuthor Commented:
It displays nothing now.

My display code:  Response.Write (qnrstatus)

The part of code I changed to embed yours (and removed the code I had before)

<%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rs_outboxall.MoveNext()
Wend

function getStatus( valToCheck )
Dim qnrstatus

select case valToCheck
    case "0":
         qnrstatus = "Sent"
     
   case "3":
         qnrstatus = "in progress"
       
   case "2":
         qnrstatus = "awaiting approval"
       
   case "1":
         qnrstatus = "accepted"
       
End select

getStatus = qnrstatus

end function
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
You have to use the code I gave you, otherwise it won't work. You'll notice I changed it to

Response.Write getStatus( rs_outboxall("IsAccepted")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.