Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Javascript/ html code for web page

Posted on 2012-04-12
3
227 Views
Last Modified: 2012-04-13
I have a web page and I want it to display different text based on a tokenS that are rendered into text on the webpage when loaded.

The tokens are C2B_NRPLANCODE and C2B_NRINSTDESC

here is what I'm looking for:

If C2B_NRPLANCODE startswith “XX”  and C2B_NRINSTDESC = "Trumpet" then
“text”

Else if C2B_NRPLANCODE starts with “YY”  and C2B_NRINSTDESC = "Trombone" then
                “text”

Else
                “text”

Can I do this?  and can I get an examle of the code?

Thanks,
MS
0
Comment
Question by:mschirad
3 Comments
 
LVL 14

Accepted Solution

by:
nishant joshi earned 450 total points
ID: 37839195
<script type="text/javascript">
var red = 1;
var result = null;
if (red == 1) {
result = 'one';
} else if (red == 2) {
result = 'two';
} else {
result = 'unknown';
}
document.write(result);
</script>

Open in new window

0
 

Author Comment

by:mschirad
ID: 37839234
yes!  

is there a way for your var to use "startswith" ?

thank you!
0
 
LVL 18

Assisted Solution

by:nap0leon
nap0leon earned 50 total points
ID: 37843432
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

792 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