code in ASP/Javascript to ASP/VBscript

Aleks
Aleks used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Big MontyWeb Ninja at large

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

Author

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") )

Author

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") )
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Big MontyWeb Ninja at large

Commented:
That should be a colon, not a semicolon on line 49

Author

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
Big MontyWeb Ninja at large

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

Author

Commented:
no luck. Same .. all say 'sent'
Big MontyWeb Ninja at large

Commented:
it may help to see the entire page worth of code, as I'm guessing the problem may lie elsewhere

Author

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
%>

----
Big MontyWeb Ninja at large

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

Author

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
Web Ninja at large
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")

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial