Creating A Switch Statement That Tests The Value Of The PartyType Parameter

Nov 14, 2009

Im creating a switch statement for this case, but dont know how to start - Create a Switch statement that tests the value of the partyType parameter. If partyType equals "D", store the following text string in a variable named barText: <td class='dem'> </td>

If partyType equals "R", barText should equal <td class='rep'> </td> etc.. So since its going to test the value of the partyType parameter, and store the text string in a variable named barText do i begin like:

[Code]...

View 4 Replies


ADVERTISEMENT

Switch Statement

Nov 1, 2005

This is my first time using the switch statement. I would appreciate your suggestion on how to do this properly. I am trying to get customer age which is (age) and compare it with the monthly rate then the text msg will display in the textarea. Also, I am having trouble figuring out how I can defined my monthlyRate in the switch or do I need to this outside of the switch? Code:
}

View 10 Replies View Related

Create A Switch Statement In A URL?

Aug 4, 2007

Is it possible to create a Switch Statement in a URL? If so, how? This is what I have so far:

<html>
<body>
<head>
<center>

<Script Language="JavaScript">
function load() {
var load = window.open(http://www.xxx.com/123456789,'','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,st atus=no');

// -->
</Script>
</head>
<br><a href="javascript:load()">Link!</a>
<br><br>

</body>
</html>

View 9 Replies View Related

Can't Get Switch Statement To Work.

Jan 17, 2010

Assignment:

Switch Create a HTML that uses Javascript. Create a page that tells a student the range their mark falls in if they know their letter grade. Below 50 is an "F", 50-59.9 is a D, 60 - 69.9 is a "C", 70 - 79.9 is a "B", 80 - 89.9 is an "A" and 90 - 100 is an "A+". You determine the input and output format.

<html>
<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN">
<head>
<title>Switch</title>

[Code]....

View 2 Replies View Related

Switch Statement Question

Jul 18, 2006

I need to write the switch statement below in a way where I can have each case with multiple values, and avoid using "break;" to allow the evaluation of the rest of cases. the code below should jump into the first 2 cases but not the last one, but it is not doing that. Is there a way for me to get around this.

function test(){
var Temp = 'cs1'

switch(Temp){
case 'cs1' , 'cs2':
alert(&#391;');

case 'cs1':
alert(&#392;');

case 'cs2':
alert(&#393;');
}
}

View 1 Replies View Related

Display Images According To Switch Statement Value?

May 4, 2011

how to display images according to switch statement value...

for example if case value is rose it has to display rose picture that is stored in our system.

View 1 Replies View Related

Using The Switch Statement And Variable Scope?

Jun 14, 2010

I've created a jQuery script that uses a switch statement. However, my experience with it, relative to variable scope, doesn't seem to follow the logic.According to the JavaScript/jQuery theory, a global variable was accessible (meaning read & write) throughtout any function within any script (one that page).However, apparently that theory wasn't completely true as it pertained to switch statements that contained variables. To illustrate my case in point, I've included a simplistic version of my code:

$("#selector").delegate("div", "click", function(event) {
var testVar = 4;
switch (this.id) {

[code]...

As shown, the variable "testVar" is not accessible from one case to the next case .Furthermore, to add insult to injury, I am seeing the same behavior within the conditional if else statement counterpart to the switch statement.

View 1 Replies View Related

Defining And Display Variables With Switch Statement

Oct 19, 2010

I'm trying to code a script that will display an approximate postage price based on different combinations of variables, but the numbers I defined for each case aren't reflected in the text box. I'm using a switch statement for all the different combinations of options, which the user will choose by selecting check-boxes. (Additionally, I know that this code probably isn't a very efficient way of doing what I'm doing - how to improve it.) I've attached all the relevant parts of the code, including how I defined variables originally.

<script type="text/javascript">
function count(){
var firstclass = document.calc.firstclass.value;
var postcard = document.calc.firstclass.value;
var numpages = document.calc.numpages.value;
var nms = document.calc.nms.value;
var large = document.calc.large.value;
var numpages = parseInt(document.calc.numpages.value); .....

View 6 Replies View Related

Display All Lines Of The Song Using A Switch Statement

Oct 6, 2011

I am trying to figure out where I went wrong in my code. The objective is to display all lines of the song using a switch statement. I thought I had my head wrapped around it, but apparently not.

View 3 Replies View Related

JQuery :: Using Case Switch Statement To Link The A Links?

Sep 14, 2010

how to get this functionality going. I have a div name "footer". Within "footer" I have 4 links:

link1, link2, link3, link4

Is there anyway to write a function which will sense which link was clicked and then alert the id of that selected link. I have written the code but am not certain why isn't it working. here is my code.

$('#footer a').bind('click', function(){
//alert($(this).attr('id'));
var mId = $(this).attr('id');
switch(mId)

[Code]....

View 4 Replies View Related

Jquery :: Detect Window Size And Then Do Something With Switch Statement?

Feb 24, 2011

i would like to check for the window size with jquery and based on the different resolutions i would like to change the background image. So i was thinking to somehow use the "switch" statement for more cases, but i just don't know how this would look like. This is the basic structure i want but with more options:

if ((screen.width>=1024) && (screen.height>=768)) {
//do something
}

[code]....

View 2 Replies View Related

Switch Statements And Variables - Creating Bars?

Apr 18, 2011

I'm having some trouble with the Switch Statements. My program runs without it so I know that the problem is here. I believe the logic is sound so it may be due to incorrect syntax. The purpose of this function is to create bars, and the length of the bars is determined by the value of the "percent" variable (which is working fine) in the For loop after the Switch statements. The variable, "partyType" contains any of the text strings, such as "I", "D", etc.

function createBar(partyType,percent){
var barText;
switch(partyType){
case "D":
barText="<td class='dem'></td>";
break;
case "R":
barText="<td class='rep'></td>";
break;
case "I":
barText="<td class='ind'></td>";
break;
case "G":
barText="<td class='green'></td>";
break;
case "L":
barText="<td class='lib'></td>";
break;
default: document.write("hi");
}
for(var i=1; i<percent; i++){
document.write(barText);
}}}

View 1 Replies View Related

Creating Code With If...else If...else Statement?

Nov 27, 2011

I am thinking of how to write the code for below scenario to create a simple online customize calculator:There is 1 box which allow us to enter any number=x (representing amount of money). So whenever we entered a number in the box and click "CALCULATE" buton below the box,there will be 3 results generated in 3 boxes below it based on the set of of rules i.e.

1. if the amount entered is <21,000

Result 1 = 1.5%*x*12
Result 2 = 1.5%*x*48
Result 3 = 1.5%*x*120

2. if the amount entered is >=21,000 and <210,000

Result 1 = 1.8%*x*12
Result 2 = 1.8%*x*48
Result 3 = 1.8%*x*120

3. if the amount entered is >=210,000

Result 1 = 2.2%*x*12
Result 2 = 2.2%*x*48
Result 3 = 2.2%*x*120

I understand that this code will involve If...else if...else Statement..

View 7 Replies View Related

Creating Textbox That Uses If Statement

Sep 9, 2010

I'm trying to create a textbox that uses an if statement. If the words vgn, vgx, vgc, pcv, pcg are typed into the textbox it will input a "-" in front of those letters in the textbox , "else" it will input nothing.
i.e:
Input: vgn
Output: vgn-

View 4 Replies View Related

Creating A Calculator That Returns An Answer Using An If/else Statement?

Nov 5, 2010

I am trying to place a Body Mass Index Calculator on a web page. I need a prompt box that asks the user to enter their weight and height (in pounds and inches, respectively). The box should calculate BMI as follows:BMI = (Weight / (Height * Height) ) * 703;After the BMI is calculated, I would like the box to display the user's status (obese, overweight, normal, underweight). After the user has entered all information, use the document.write function to display the following, with the customized information:

Height
Weight
BMI
Status

View 3 Replies View Related

JQuery :: How To Run 1.4.2 Qunit Tests

Jun 25, 2010

I am only been able to find 1.3.2 jquery.com/test But I am interested in 1.4.2 testspecifically AJAX testing since I can't get ajax GET/POST requests to work using 1.4.2 on IE8 (it works fine in FF and Safari)

View 2 Replies View Related

Site Check Partners For Ajax Smoke Tests

Jan 3, 2007

I'd like to join or start a small group of Ajax web developers who are
willing to smoke test each others Ajax applications, quid pro quo.

I can smoke test on W2K SP4 with IE6, FF2, SM 1 and O9.

I need the following smoke tests:
IE7 on XP (are they SP1 or SP2 now?)
IE and FF on VISTA (any SPs yet?)
SAF, IE and FF on MAC (Panther, Tiger, ...?)
KON and FF on LINUX (Debian, Ubuntu, ...?)
other Ajax-friendly browsers...?

I'm talking about something a small group of mature developers can do
to help each other, without anyone being neglected or taken advantage
of.

View 4 Replies View Related

Regular Expression That Tests A String To Find Out If Not Empty

Jun 25, 2010

Just a quick one here I want a regular expression that tests a string to find out if not empty. I am currently using /^[a-zA-Z0-9]+$/ which allows all alphanumeric characters, however unfortunately does not allow white space. As I am trying to use the RE for a form name input and I don't wish to separate first and last name, I want to allow users to enter their full name including spaces. Can anyone tell me an RE that allows all alphanumeric characters and white space in a string but does not allow an empty string

View 14 Replies View Related

If Statement Returning False On A True Statement?

Apr 4, 2011

my webstie allows users to change the color of the background, so to keep the text readable I have it changing as well.the color picker I am using has text boxes with rgb values 0-255 for each.I am trying to get one bit of text to alternate between red and blue with the conditions

Code:
if(blue>green && blue>red)
{

[code]....

View 2 Replies View Related

Switch Problem

Jul 23, 2005

I have some function to Preload images and make MouseOver etc..

But when a put a Switch statement in one of my function (MouseOver), a
receive an error on body load in my preload function.. did someone have any
idea why ?

Here's my switch code :

function setOver(num)
{
var txt;
obj = eval('document.getElementById("image' + num + '")');
obj.src = imagesHover[num-1];

txt = '<img src="' + imagesInfo[num-1] + '">'
document.all("infoDiv").innerHTML=txt;
document.all["infoDiv"].style.display='block'

Switch (num)
{
Case 1: alert(num);Break;
Default: alert("hello");Break;
}
}

View 2 Replies View Related

Make An 'on' 'off' Switch

Mar 23, 2009

I'm trying to make an 'on' 'off' switch

the idea is for imgA to 'toggle' with imgB onMouseDown (onclick is used to call a function)

I can get the image to swap once but not back again. I have no idea if the way i'm attempting it is even close.

<script type="text/javascript">
function imgswap(){
if ( )
{

[Code]....

View 8 Replies View Related

Switch Menu

May 14, 2007

I'm trying to install a menu for my website. I am using a script I found here: http://www.dynamicdrive.com/dynamicindex1/switchmenu.htm.

The code works great, but I would like to customize it slightly. Instead of being a vertical menu, I would like it to be a horizontal one, with all the main links at the top of the page, and with each link opening a horizontal sub menu beneath it.

I managed to create a horizontal list by changing the 'div' to 'span' and altering the HTML and CSS slightly. Now I have a horizontal menu that opens submenus when I click!

My only problem now is that instead of opening each submenu below all the links, it opens it below the link in question. So, for instance, let's say I have three links: Info, About, and Contact. If I click on 'About', it opens up a submenu under Info and About, and pushes Contact down to a new line below the submenu. If I then click on 'Info', it closes the previous submenu and opens a new one below Info, with About and Contact in a new line.

My JavaScript skills are pretty poor, so I was wondering if someone could help me identify where in the JavaScript I need to make changes so that the the submenus open below ALL the menu elements. Code:

View 2 Replies View Related

Switch Ie/firefox Css

Feb 2, 2005

im looking for a nice javascript cde which switch css link href when browser is detected.

View 9 Replies View Related

Switch Function

May 31, 2007

I am using a switch function to toggle those links for display and unlink image will be hidden. But I have just duplicated the first block of javascript for the second tab, it didn't work. This is the first block of switch function, it works for first tab: Code:

View 4 Replies View Related

Switch Off A Js When Printing?

May 6, 2010

I'm trying to make a printable version of a webpage using the css @media tag. On the page is a javascript which works great for the on-screen version but I need to find a way to switch it off when printing as it hides content.

Beyond building a separate page I can't think of anything obvious!

View 1 Replies View Related

Multiple Arguments In Switch?

Jul 23, 2005

As I can remember this is not allowed in Java:

int x, y, z;
switch(x,y,z){
case 1,2,3:
System.out.println("Hep");
break;
}

But what about in JavaScript, or are there some other kind og syntax for switch?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved