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
ADVERTISEMENT
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
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
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
Sep 23, 2008
I would like to do a switch in javascript, with multiple values in the case. code...
View 14 Replies
View Related
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
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
Nov 5, 2004
I am having trouble creating a page that stimulates a large number of dice rolls and computes the average of the dice totals in an separate text box. Code:
View 1 Replies
View Related
May 1, 2010
Obviously I'm not quite understanding .not() because the following code does not perform identically:
if(!$(this).is('.current')) { some code }
and
if($(this).not('.current')) { some code }
So that I can make use of .not(), how would I write the second conditional so that it performs as the first conditional?
View 2 Replies
View Related
Dec 8, 2009
I am somewhat a noob at js/jquery so I wasn't sure exactly how to do this. Think I just need a push in the right direction. Basically I'm trying to validate a form (jquery validation) with a couple of conditionals based on a selection box. So I have:
<form id="info" class="validate">
<select id="select">
<option value="senior">Senior Citizen</option>
[code]...
I'm trying to validate that if the user has selected "Senior Citizen" then their age must be 65 or older (and validate the adult/child ages as well).
View 6 Replies
View Related
Jul 23, 2005
I have a multi-language site. Texts are drwan from
a mySQL db. At the contact form, there are a few obligate fields.
Because the Javascript that processes the form
is an external js file, it cannot handle PHP.
So i wonder if there is a cross browser/platform way
to get the value of the labels that belong to certain
fields, so i can put them in an alert box.
View 1 Replies
View Related
Aug 10, 2009
I have this js file which basically is a UI screen. This screen displays lot of labels to the user.
I need to externalize this label from .js file. What i mean by this is, i will be storing my label names in a table and will fetch it from DB before i load the .js file and show it in UI.
How do i make these labels dynamic? Can i get the labels from DB using a .vb function (.vb file) and call this function in the .js file? Or is this not possible at all.
View 5 Replies
View Related
Oct 20, 2010
I want to display an image and when a user mouses over the image, i want a label to pop up. I've done this before, but I've forgotten how.
View 2 Replies
View Related
Mar 20, 2006
In my application some of my data which is coming in text boxes is in arabic. in database i can see arabic chars properly , but in text box it is appearing in strange chars. even if i try to write arabic in code itself to be appear in some headings they are appearing in some boxes.
View 1 Replies
View Related
Aug 20, 2009
My HTML markup contains:
Code:
<div id="options">
</div>
[code]....
View 3 Replies
View Related
Dec 1, 2010
Please look at the following comment form:
http://docs.jquery.com/Plugins/Validation
There's a similar one on this page:
http://jquery.bassistance.de/validate/demo/
I'd like to put the labels on the right of text input fields and display the error messages under input fields.
Tried almost anything, but to no avail.
View 4 Replies
View Related
May 6, 2009
Consider the following select box:
<select id="test">
<option value=""></option>
<option label="XS" value="1">XS</option>
[code]....
View 8 Replies
View Related
Aug 28, 2011
I found a same issue somewhere the jquery replaceWith comments sections, I would just reiterate it as its the same problem Im having now,My requirement is that on click of edit button , Labels are replaced with Textboxes . Once user Updates in it . Once Update button is clicked , Text boxes are replaced with labels again with updated text .But problem is this works only once .If User clicks on Edit button again then , Labels are not replaced with textboxes ..as labels are virtual labels .Step 1 : Click Edit ButtonStep 2 :
$("#LabelID").replaceWith("<input id="txtID" type="text" value=""+ LabelCurrText +"">");Step 3 : Click Update buttonStep 4 : $("#txt1").replaceWith("<label id="LabelID">"+LabelUpdText+"</label>" ;Perfect.Step 5 : When user again clicks on Edit buttonStep 6 $("#LabelID" .replaceWith("<input id="txtID" type="text" value=""+ LabelCurrText +"">");Same code but doesnt work.. or say it doesnt get replaced with.I have almost the same scenario, with some twist, so here's mine,I click a link -> load the details of the link on a modal -> do some editing on the modal -> save(without closing the modal) -> update the data on the modal
it works for the first time, but succeeding clicks no longer results as expected (there are sometimes its not firing also).
View 7 Replies
View Related
Mar 11, 2011
I am trying to create Dynamic TextBox using JQuery. What i am trying to create is when I enter a number in a textbox say "5" then 5 new text box will appear below it with labels. But not able to make it.
View 1 Replies
View Related
Oct 1, 2009
I'm using a form in several places for this project. I don't want to duplicates of this form so I have it as an include file. Each page requires all the same fields, however, there is one page where I'd like to remove two fields.
<fieldset>
<label for="FirstName">First Name</label>
<input id="FirstName" />
</fieldset>
Is there a way to remove an input field and it's label by selecting the ID of the input field? I looked at the JQuery doc, and there's a prev + next selector which shows $('label + input').css ... this will set css properties for an input element that follows a label element. something like $('#FirstName > label + input').remove...
View 2 Replies
View Related
Oct 5, 2010
I have a php-based form with radio-buttons with following labels - I've been trying to get the text-value of these labels, but I keep getting empty variables - it seems it doesn't pick up the value at all.
Here's some of the code:
<li><span class="radioinput"><input class="crirHiddenJS" id="this_pulje_
<?php echo $pulje['pv_ID']; ?>" type="radio" name="
<?php echo $pulje['p_subname']; ?>" value="
<?php echo $pulje['pv_ID']; ?>"></span><label for="this_pulje_
<?php echo $pulje['pv_ID']; ?>"><strong>
<?php echo $gametype; ?>, M: </strong>
<?php echo $pulje['pv_module']." <strong>S: </strong>".$pulje['pv_system']."
<strong>GM: </strong>".$pulje['pv_GM']; ?></label></li>
Which outputs something like this:
<li><span class="radioinput">
<input type="radio" value="47" name="pulje_2" id="this_pulje_47" class="crirHidden">
</span><label for="this_pulje_47" class="radio_unchecked">
<strong>R, M: </strong>Bergen 2192 <strong>S: </strong>Blue Planet v2
<strong>GM: </strong>Thor André Karstensen</label></li>
And then I have the following jQuerycode, which doesn't return anything:
var radioContent = $("#"+prevTarget+" :radio:checked").next('label').text();
As for the "prevTarget" it's being populated, because if I change the above to this:
var radioContent = $("#"+prevTarget+" :radio:checked").val();
It returns the value just fine. But for some reason it doesn't return the text from the label - and I don't really understand why. Test-page found here: [URL]
View 2 Replies
View Related
Dec 17, 2010
I'm trying to develop a form piece that has multiple radio buttons. Selecting a radio button will display a set of options relating to that radio button. Clicking on the label (which will be an image in this case) should do the same. I have the radio button part working and am having trouble with the labels. Clicking on a label selects the correct radio button... but the content for that button is not displayed. I know I can probably work around this in the same way I am addressing the radio button change events, but I don't want to introduce more code than I need. With that being said, I also know there has to be a more efficient way to tackle the radio button change events since they all do the same thing and only the value is changing.
Here's a stripped-down version of what I am working with. I'm looking for someone to help me make this work correctly and, equally as important, address the inefficiencies in my coding approach.
[Code]...
View 1 Replies
View Related
Jul 1, 2010
The way I have my form set up, I have a line break between the input fields and their labels. By default, the Validation plugin puts errors after the input field. I am trying to put the errors next to the labels so it looks like...
Name: This field is required. [ ]
I've read the documentation and tried modifying the errorPlacement example, but I never got it to work the way I want it.
Here is the form I am using.
View 3 Replies
View Related
Apr 16, 2011
Im having problem generating the labels for content created by the following function:
function setOutput(){
if(httpObject.readyState == 4){
var answer = httpObject.resultsponseText.split(",");
var results = document.getElementById("resultsultadosScan1");
var article = document.createElement("div");
var weight = document.createElement("div");
var price = document.createElement("div");
article.className = "article";
weight.className = "weight";
price.className = "price";
document.getElementById('outputText0').value = httpObject.innerHTML= answer[0];
document.getElementById('outputText1').value = httpObject.innerHTML= answer[1];
document.getElementById('outputText2').value = httpObject.innerHTML= answer[2];
article.innerHTML = httpObject.innerHTML= answer[0];
weight.innerHTML = httpObject.innerHTML= answer[1];
price.innerHTML = httpObject.innerHTML= answer[2];
results.appendChild(article);
results.appendChild(weight);
results.appendChild(price);
}
}
A friend wrote this sample script to achieve generation of labels on my script, but I have been trying for hours with no luck, can someone take a look and tell me the correct usage of this script:
Code:
function createLabel() {
var target = document.getElementById("target");
var label = document.createElement("label");
var text = document.createTextNode("Article");
label.appendChild(text);
target.appendChild(label);
}
Can you help me with the correct "combination" using my script above, a "real life" example?
View 9 Replies
View Related
Oct 26, 2010
I'm trying to make watermark labels for both my username and password fields. Currently the password field displays the password watermark in asterisks. I only want asterisks to be displayed when a user types in values. Here is an example of what my login looks like with the word password in asterisks when someone loads the page.
<div id="username">
<input id="username-field" class="loginFields" type="text" name="username" title="Username" value="Username" />
<script type="text/javascript">
[code]....
View 2 Replies
View Related
Jul 20, 2010
I'm trying to customize the position of my labels through the option errorPlacement, but I still didn't find how to make it work, I want to display icones just after my inputs, and my labels in a div, I tried to use errorLabelContainer for the div, but still can't display my icons (you know, a simple check mark when the input is valid, and a red cross when not).
View 1 Replies
View Related