Does If, Else If Require An Ending Else?
May 13, 2006
For a long time I have been using:
if
else if
else if
else if
For example, I'm using it now to put different ads on different forum pages after checking the forum number in the URL. If there's no match, I don't want an ad on the page.
Is my code above "legal" or does it require an else at the end?
BTW, the reason I do it that way instead of just using ifs is that I figured that once it found a true condition it wouldn't bother reading the following else ifs and that would save time... it would run faster.
View 6 Replies
ADVERTISEMENT
Jun 28, 2006
Cookie name is "viewStatus" value saved is 1
Closing all windows should end the session but on the reopening cookie page I find the session cookie is still alive.
If I alert(document.cookie) I get viewStatus = 1
If I rename the cookie to say "vStatus" and close the window when I reopen it and alert(document.cookie) I get
viewstatus=1 vStatus=1
any ideas?
This only happens in IE ( as always)
PS
I just did a little experiment, I closed all windows, created a new file with just
<script>
alert(document.cookie)
</script>
in it then opened the file and still got
viewstatus=1 vStatus=1
I know I did not have this problem before because I have a session cookie example on my site and that does not work now so is it something new that is wrong with IE.
View 2 Replies
View Related
Nov 9, 2010
I'm using some jQuery to create a playlist for jPlayer. I have all of my songs indexed in a playlist that I have created like this:
var playlist1[
{ name: "song1", mp3: "/media/songs/song1.mp3" },
{ name: "song2", mp3: "/media/songs/song2.mp3"},
[code]....
View 2 Replies
View Related
Dec 13, 2009
I have an assignment for a class that I am not sure how to approach. A string, a noun, is input and the program is supposed to make it plural based on the ending. If it ends in a double consonant then I add one ending, if it ends in a vowel I add a different one and then if it ends in two vowels or two consonants I add a third, different ending. I am supposed to do this using string methods. For the project the vowels are A, C, L, and S. I have to read the data in using the string tokenizer. I am not sure how to approach making the loops I need to use to make the words plural.
View 7 Replies
View Related
Jul 12, 2011
I need to find all rows in a table ending with an id.. $("element[id$='txtTitle']")
this will work fine i know.... but i want to find it inside it inside another table whose id i have and not the whole document.. how do i achieve this??
View 5 Replies
View Related
Dec 7, 2009
I am using javascript to verify a text input box but I would also like to require atleast 3 characters being entered before allowing the user to search.
View 6 Replies
View Related
Sep 22, 2010
Here is my issue that I am trying to resolve. I know how to make a field in a form required for validation however what I am trying to do is require that at least one of two available fields is filled in. The form performs a search using the 'first name', 'last name' or both. What I need is for the form to require at a minimum that at least one of the two fields is filled in prior to sending it to the script to do the search.Here is what it should do in each instance:
[first name] [NA] = form submitted
[NA] [last name] = form submitted
[first name] [last name] = form submitted
[na] [na] = Not submitted
View 7 Replies
View Related
Feb 12, 2010
I'm playing with a greasemonkey script and would like to provide geo-locating. The geolocation services I've found all require dev/api-key. A dev-key means I reveal my well-earned key, or an api-key usually means a server address... there would be none via a greasemonkey script.
View 6 Replies
View Related
Apr 24, 2009
So I understand you can do:
$(".className").xxx.
Is there an easy way with jquery to have it match 2 classes. So maybe I only want the action to take place it the element has class1 and class2.
$(".class1" , ".class2").xxx
The above is close to what I would like, but thats if any of the 2 classes match, go. I need it to be both. I can probably do this with some basic javascript logic.. just figure there may be a function for this already.
View 4 Replies
View Related
Jan 11, 2011
How can I validate that if the user enters a quantity in the field they also must select a reason code. How can I do this.
<form name="theForm" onsubmit="validate()">
<table>
<tr id='Child1'>
[code]...
View 4 Replies
View Related
Jul 18, 2011
As you can see below in example #1I am attempting to assign a variable value to the 'URL:' key. I am having problems with this Ajax call but I don't know if this is the cause. I even tried using eval() in example #2 below. I am pretty new at this stuff so forgive my ignorance.
Does the 'url::' key REQUIRE a literal string?? Is there no way to set this value at run time?
[Code]...
View 1 Replies
View Related
Mar 8, 2010
I have a simple form with a sum.
Sum is 4 + 1 = ... the answer will of course be 5.
Does any one know of a simple tutorial where a specific number can be entered into a text field. If number is incorrect it pops up a simple error box.
View 2 Replies
View Related
Oct 26, 2010
I'm trying to set up a form that has a text field that is required to be blank - I'm dealing with form spam, and the bots are stuffing every text field with random crap. So, I have a text box that is required to be blank. But I can't get jquery.validate to understand both required and blank.the text input is has a name and id of live_check.I have added this method:
$.validator.addMethod("equalToParam", function(value, element, param) {return value == param;});
and then my rules look like this:
rules: {
first_name: "required",
last_name: "required",[code]...
But validate flags the empty text box as invalid (because it's required?)
View 3 Replies
View Related
Aug 30, 2010
I want to add a simple alternative to CAPTCHA on a form by adding a required text input - e.g.Type the word "jquery":How do I add a rule requiring a specific value?
View 5 Replies
View Related
Apr 26, 2011
I have an issue with a registration form. What I would like to do is only allow a certain email domain in the 'email' field. Eg. Only allowing @gmail.com email addresses, and all others would receive an error. This is the line of code that I believe needs changing:
function isEmail(valor){if(/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,4})+$/.test(valor)){return(true)}else{return false;}}
I am not too familiar with this but through my hours of research, I believe that I need to add something to this line.
View 7 Replies
View Related
Apr 21, 2011
I have 2 radio buttons:
[Code]...
View 1 Replies
View Related
Jul 30, 2009
I am trying trying to create a site that will require a database. (much like facebook functions)
I am not new to programming, as I know Java and C++, but I am very new to the web development.
For security reasons (so I have heard), I would like to write this site in php. At the same time, I may need some client sided code. (Or do I?) I am not at all sure.
I know that facebook is written in php, and the site I am making basically has the majority of those functions.
Any inputs as to how I should go about choosing what language? As of now, my partner is learning javascript and mysql, while I am studying php and mysql.
I know that some sites implement both, javascript and php, but I was wondering if it is at all necessary to use both, and how would one know which code to write in what language.
View 8 Replies
View Related
Sep 23, 2009
I have a working example of jQuery validate working in the link below. The newsletter checkbox is required and working. However, the "colors" checkboxes are all named as an array ( ex: name="color[]" ), and so the problem lies in the validation code, where it uses the name of the element to require elements ( ex: newsletter: "required" ).
Code JavaScript:
<script>
$("#testform").validate({
[code].....
View 2 Replies
View Related
Jun 27, 2010
I don't quiet understand how to require a valid email address to be entered into a particular field.
There is documentation for what I wish to achieve here[code]...
But I'm having trouble understanding it.
For a start, I can't quiet tell from examining the demo how a particular field is required to have a valid email address.
I can't tell how the script picks up which particular fields are required to have which rules.
View 3 Replies
View Related
Sep 28, 2009
Info:- jquery-1.3.2- jquery.validate-1.5.5- form with 1 dropdown select and 4 text inputsSetup:- all 4 text fields are not initially required.Issue:The first input element is a required dropdown select.If the user selects option 1, then text field 1 & 2 need to be
required.If the user selects option 2, then text field 3 & 4 need to berequired.How do code this?
View 3 Replies
View Related
Jun 29, 2011
I prepare a contact us page for my site.URL...when click on submit button 2 or more times the message is set for require field is increasing.
View 1 Replies
View Related
Oct 10, 2007
I am trying to create a javascript form validation that will make a text field be required only if a previous text field is populated. If the first text field is blank, then the second field can be blank as well.
View 2 Replies
View Related