Solved

Position of Charater in string

Posted on 2009-04-06
2
239 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
ID: 24077470
>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
ID: 24077677
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can I clean log of  running tomcat 7 server ? 3 125
Display current date,month,and year to JTextField 3 47
gZip compression filter 2 118
maven webservice example issue 2 122
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

21 Experts available now in Live!

Get 1:1 Help Now