Solved

Javascript/ html code for web page

Posted on 2012-04-12
3
226 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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).

785 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