Solved

Position of Charater in string

Posted on 2009-04-06
2
236 Views
Last Modified: 2012-05-06
we have a product that uses Javascript to produce dashboard information running on websphere 6,

i'm looking at a way of returning the day name / number 1-7 from a string of charaters,
I have a string that would contain 7 charaters similar to this 'NNYNNNN' the 'Y' means we deliver to this customer on Wednesday so i need to return '3'  i can do a case ect to trun into wednsday. problem is there can be more than one 'Y' so there would be to many combinations to do in if statements,

in VB i would use indexof,

is there a similar function in javascript?
0
Comment
Question by:IanPaskin
  • 2
2 Comments
 
LVL 27

Expert Comment

by:rrz
Comment Utility
>is there a similar function in javascript?  
Do you mean JSP  ?     If yes, then  you could use something like  
<%
     String s = "NNYNNNN";
     if(s.charAt(2) == 'Y') out.print("yes");
     else out.print("no");
%>
0
 
LVL 27

Accepted Solution

by:
rrz earned 250 total points
Comment Utility
Javascript is similar. use this test  page

<script>
  function test(){
          var s = "NNYNNNN";
          if(s.charAt(2) == 'Y') alert("yes");
          else alert("no");
  }
</script>
<html>
<body onload="test();">
</body>
</html>
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now