Solved

Position of Charater in string

Posted on 2009-04-06
2
242 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Troubleshooting common task sequence error codes
How do we balance the user experience (UX) with reasonable security measures? It can be done, if you keep these fundamentals in mind.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

19 Experts available now in Live!

Get 1:1 Help Now