Solved

Position of Charater in string

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lamba in java 8 9 252
IE doesn't Invoke servlet in iframe 1 121
struts hibernate integration example 28 147
by zero exception 10 70
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
This article discusses how to implement server side field validation and display customized error messages to the client.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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