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


ADVERTISEMENT

Conditionals In Switch 'case' Labels

Jul 20, 2005

Is this sort of thing possible:

var X = 'Moe'
switch (X) {
case 'Curly'||'Moe'||'Larry':
alert('Found one of the Three Stooges');
case 'Chico'||'Harpo'||'Zeppo'||'Grouco'||'Gummo':
alert('Found one of the Marx Brothers');
default:
alert('No matches');

This gives 'No matches' unless I only put a single string in the 'case'
lines. I've just been using VB's Select Case which is a similar flow
control but which allows conditional arguments in the 'cases'. I just
wondered...

I realise you could put each set of names in an array and iterate
through each array, but that's a different issue.

View 4 Replies View Related

Set Element Visibility Using Switch/Case?

Nov 19, 2010

So, I have a list of items that need to have a new preset list item appear based on what day it is. I have the date script working (to test, change the first case to some random date and change the third case to todays date - 10192010 - It will fire that document.write). What I need the cases to do though, is set the visibility of certain list items.

This is just an example, there will be around 20 list items in the final project. As you can see in the first two cases, I've tried a couple different routes to no avail.

The Code (class references are irrelevant to this example, they belong to the final project):

<html>
<head>
<script type="text/javascript" language="JavaScript">
/*

[Code]....

View 2 Replies View Related

Use Logical Expressions In A Switch / Case?

Aug 31, 2009

I'm doing a bit of experimentation and would like a bit of advice if possible please.

In my switch statement I would like to use the || or operator, it works correctly it I set the case to 31, but if I try 1||31 it doesn't.code...

View 4 Replies View Related

Switch(n) Does Not Correctly Evaluate Case / Solve This?

Oct 18, 2009

I am returning the present time - then using the .substr to remove all digits except the last two on the right (i.e effectively returning the value 32 from 65344532) I am then looping, subtracting 11 from that number until the value is less than 11. The intent being to then return the value from the appropriate matching array ID code...

The problem arises with evaluating two digit numbers beginning with zero - In cases where the last two numbers are greater than 09, the looping returns a 1 digit number for valuse less than 10, in cases where the last two digits begin with zero the loop will not begin. I have attempted to use the switch(n) to determine if any 01, 02, 03 ... etc exists but this is not evaluating correctly - is this due to using the date/time object and if so is there a good way to convert this to either a numeric or string datatype where the case can be evaluated correctly?

View 11 Replies View Related

Switch In Script With Multiple Values In Case?

Sep 23, 2008

I would like to do a switch in javascript, with multiple values in the case. code...

View 14 Replies View Related

Switch Case Detect For Multiple Values More Efficiently?

Sep 7, 2010

I know this does not work, but hopefully you can see what I am trying to do. Only the first value is tested, but I want all of them to be.

[Code]...

Pretend there are like 10 more cases with more numbers with them. Currently this will only text to see if x is 0 or 42. How do I get it to test for the other numbers?

View 7 Replies View Related

Javascript Case Statement

Mar 3, 2006

I am writing some javascript code and just wanted to check if a case statement could have OR / AND. If yes, what would the syntax be like.

What I need is this:

switch (country) {

case "US" || "Canada":
//do something
break;
case "Australia" || "UK":
//do something
break;
}

I can alternatively use IF statement but was curious.

View 2 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 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

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 View Related

Switch ID On Link Not Working?

Sep 20, 2010

I have a few links on my website as follows: <a href="javascript:switchid('a6');">Link 6</a>but when I view source it comes out like this: <a href='javascript:switchid('>Link 6</a>

View 11 Replies View Related

Getting Switch Image To Be A Link As Well?

Apr 13, 2011

I'm trying to create a switch image code that will allow the new image to be a link as well. In the list item where you'll see ('blue.jpg') if I try to make this an anchor tag - it breaks the code.

<head>
<script>
function switch1(div) {
if (document.getElementById('blue')) {

[code].....

View 6 Replies View Related

JQuery :: Select A Links Href Value, Then Load That Link Into A Div?

Feb 10, 2010

I have a 2 column page.Left nav which contains a list of items with links to their respective details page.What I'd like to do is to load that link into the div in the right side of the page.want to do this via Ajax, so I don't have to reload or redirect the page.I do have my layout coded, but my jquery code is not even close to work, so I didn't post it here.

View 3 Replies View Related

JQuery :: On Link Click - Reload Whole Page - Show Only The Content For The Links

Aug 6, 2009

I'm using a jquery slider for displaying content on a webpage.

[url]

Like in the first examples i have 5 panels, and i have a meta navigation, contact, links ect. all thedifferent content for the meta-navigation is displayed via jquery in panel 5, and is working fine.

Now my question; when the user is for example on the second panel, and the clicks on links, the page should show panel 5 (which is the index page(default.asp)), and then show only the content for the links.

I tried different stuff for loading the defautl.asp page, but it doesn't work. how do i tell, that if i click on the link wirh class="kontakt" the page should load the default.asp, and THEN do all the jquery stuff?

Below is one example, what i tried, but did not work.

View 1 Replies View Related

Detect Viewport Width And Link Stylesheet With If Statement?

Jun 12, 2010

write a PHP script that detects the user's viewport width, and I am guessing stores this in a variable, then checks if it is less than or equal to 1024px using an if statement and if so attaches a certain stylesheet, lets say alternative.CSS, but in the else part of the statement; therefore, if the viewport width is greater than 1024px, it attaches or links default.css

View 8 Replies View Related

JQuery :: Cycle Plugin - Code - Get My Slides Links To Link To My Other Slide Page

Oct 18, 2010

Someone kindly produced some code for me so I could get my slides links to link to my other slide page. The thing is I am using the "pagerAnchorBuilder" option on my original slide and I cannot seem to get the new code I was given working with my code on my website. Can someone advise me on how I can get the new code working with thepagerAnchorBuilder.

My Website Code:

New Code:

View 9 Replies View Related

JQuery :: Dynamic Link Generation - Convert Words With A Certain Class Attribute Into Wikipedia Links

Jun 9, 2009

There's a feature I want to implement, but don't really know how to code. The intention is to use jQuery to convert words with a certain class attribute into Wikipedia links.

An example to make things clearer:

PLAIN TEXT: There is a <span class="wiki">penguin</span> there.

EXPECTED RESULT: There is a <a href [url] there.

Hence the code would have to grab the string of words inside the tag and place them inside a href with the first part of the link already attached to it. Doesn't seem too complicated, but I wasn't able to do it.

I have been trying to use the code below (created by Patrick Haney and improved by enraged) as a basis, but no deal. This code subistitutes words for code, but it searches for specific words.

If anybody knows a script like that, modify the code below,

View 7 Replies View Related

Close Open Links On Click Of Another Link?

Jun 9, 2009

I have 3 links that are clickable... And what I want to do, is when 1 anchor tag is open and the user clicks on a different link, it closes the previous link and opens the clicked one. Here's a link to the working page to see my example: Example Site on Temp server The green buttons on the right hand image are the clickable links and these are the ones I want to add the final animation to. Click on one link, then click on another.

[Code]...

View 4 Replies View Related







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