Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

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
Avatar of Big Monty
Big Monty
Flag of United States of America image

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

Avatar of Aleks

ASKER

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") )
Avatar of Aleks

ASKER

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") )
That should be a colon, not a semicolon on line 49
Avatar of Aleks

ASKER

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

Avatar of Aleks

ASKER

no luck. Same .. all say 'sent'
it may help to see the entire page worth of code, as I'm guessing the problem may lie elsewhere
Avatar of Aleks

ASKER

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

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

Avatar of Aleks

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial