Conditional Statement Doesn't Work Correctly
Dec 6, 2009
Code:
Red part in the code above is for conditional statement.
But the conditional statement doesn't work correctly.
How can I make the conditional statement correct in javascript?
View 24 Replies
ADVERTISEMENT
Jul 23, 2009
I'm having a problem with my radio buttons. On FF and Chrome they work just fine, but in IE, they does'nt appear as sellected. In other words: they do their job, but when you click'em, they stay unckeched. The genetarion code:
var item = $('<input type="radio" />').attr('value',pid).attr('name',name);
self.append($('<p />').append(item).append('<label>'+desc+'</label>'));
View 1 Replies
View Related
Mar 25, 2010
this is a re-post of the last item in ':after in js?', below, but the problem is no longer about ':after': now there's an 'else if' statement that doesn't work. This works: it looks for 2 conditions in a class name, and changes a class:
[Code]....
View 2 Replies
View Related
Feb 19, 2010
I have an input form that accepts numbers. I am trying to compare the last field value to the current field value. My problem is that when I use the variable name of the last field in an object path, I get the error "null or not an object". The var 'L' is the problem in the statement below. If I manually type the field name in place of 'L', it works fine. How do I have to write this statement so 'L' works?
Problem statement:
c=window.document.save_info.L.value;
Here is my code: Form element:
Code:
<input style="border:1px solid gray; background-color: #FF9;" onkeyup="moveOnTwo('frm_score1',<?PHP echo $num_holes; ?>,this,'frm_score2')" size="1" maxlength="3" name="frm_adjsc1" id="frm_adjsc1" />
JavaScript Function:
Code:
function moveOnTwo(lastFieldID,holes,field,nextFieldID){
var L = lastFieldID ; var N = nextFieldID;
[code]...
View 3 Replies
View Related
Sep 1, 2011
I have a simple problem that I can't solve. I am trying to code a "More Info" button/link to display some more technical details of an item, if required or wanted. I haven't tried incorporating any code in to my web site yet, first I am trying to test how it can be done in a seperate file.
What I have right now is a table with two cells. In one cell is static text, in the other is a hyperlink. The onClick event calls a JS function called "more_info()" in which a global varible is altered to contain the value 1.
Directly after these two cells is more JS (this is before the table ends). The JS here is checking to see whether the value of the global variable has been changed. If the value is 1, display information. There is no "else" clause because I don't want information displayed unless the variable is equal to 1, so it is not required.
I think I know what the problem might be. The browser is reading the code in question before I ever click the link and has already been executed before the variable is changed. I know JS is object oriented so it will not sit there waiting for me to click the button before reading the logical statements.
[Code]...
View 6 Replies
View Related
Nov 19, 2010
I have a JavaServer demo I'm working on with a bit of JavaScript and thought I'd try adding some AJAX. Its a forum, and the idea is that a post window is revealed when the reply message is clicked. This button is in a jsp page has an onclick attribute to the showEditor() function below. A cancel button is similarly hooked up to hideEditor(), and the submit button calls copy() with a onsubmit tag. A servlet sends a response which has both the HTML for the post area (its a rich-text editor in an iframe, with a bunch of buttons above it much this one) and a Javascript object called Editor that has handlers for all the buttons and sets up the iframe so it is editable.
I actually got it to work okay, until I removed the last alert() I was using for debugging. Then the iframe stops being editable, and the editor.appendQuote() function either doesn't work or doesn't run.
This isn't terribly important because all AJAX accomplishes here is not sending all the post-related HTML and Javascript unless it is actually needed, which isn't all that much, but it would be nice to figure it out anyway.
Code:
<script type="text/javascript">
var editor = null;
function showEditor(node) {
if (node != null) {
[Code]....
View 2 Replies
View Related
Dec 28, 2010
I'm trying to write a modal login script which I borrowed from the SimpleModal site. Unfortunately, I'm running into a very frustrating problem.
When the user types in a valid login/password combo, the PHP function do-login.php echos back "OK". That being said, here's a snippet of my jQuery code:
$.ajax({
type: "POST",
url: "do-login.php",
data: str,
[Code].....
The do-login.php script DOES echo back "OK"- I verified that with Firebug. But even though it echos back "OK", it goes to the 'else' clause.
I tried using return instead of echo but that didn't help either.
View 18 Replies
View Related
May 3, 2011
Code? What is the correct way to write it.
Rules: create an array for the user to type 5 strings in a prompt that will be displayed in an alert box.
User must type in the prompt an alert will display what the user typed if the prompt is empty or contains nothing an alert will display telling the user to enter text user clicks ok on the alert box and is sent back to the prompt box
View 14 Replies
View Related
Jun 18, 2010
So I'm new to jQuery and loving it! I just got stuck on a problem that I'm not sure how to work around. I'm trying to add a class to a li item in a navigation if it has child list items underneath it. For example,if I have this situation:
[Code]...
View 1 Replies
View Related
Nov 11, 2011
I am posting two variables to a php page:
$.post('poll_receiveData.php', {question:currentSlide, vote:vote},
function(output){ ... })
}
currentSlide is set to 0. vote is set to 2. When I look at my console log, these are true. But in poll_receiveData.php, I'm unable to use a conditional statement with $vote. It's like the program doesn't know how to compare things to $vote. But a SQL statement using $question works just fine. Here's my code:
[Code]...
View 1 Replies
View Related
Apr 13, 2010
I am not a javascripter however I have a simple need to a yes no question before someone can fill out a form. Bloew is what I have. If they click yes I'll take them to the form, if no then I will redirect them to a different page. I can not get it to work.
Code:
View 2 Replies
View Related
Feb 20, 2010
I am starting to learn javascript and I had a quick question. I know actionscript and java, so this my mistake here is probably context...but I cant seem to figure it out. I'm trying to figure out how to create a conditional statement based on what button a user clicks. Here's my code:
[Code]....
This doesn't seem to work. Am I referencing this.value incorrectly? If so, what's the proper way to get information about what the user clicked?
View 4 Replies
View Related
Dec 8, 2011
I am trying to test the id of three input boxes so that I can capitalize the first letter.
The fname and lname work fine but mi does nothing and I get no error is this because of the if statement or the fact that the mi only has one character?
View 1 Replies
View Related
Mar 8, 2011
JQuery and I have a function which adds an image to a link depending on the file type.
How to write a statement that says....if there is no file extension - leave the default styling, if not add file extension. At the moment I have dots and images..see here [url]
View 8 Replies
View Related
Feb 22, 2011
In the attached code the outcome always defaults to the first test, even if the condition is false. How would I alter the syntax so that both condtions are evaluated?
Code:
var res = document.calc.num1.value*100/document.calc.num2.value;
function cost1()
[code]....
View 3 Replies
View Related
Jun 20, 2011
I found this script for a navigation fade-in/fade-out and I want to modify it so it'll only trigger the fade-in/fade-out functions of the span class is NOT set to active. Here is the javascript:
Code:
$(function() {
$("#nav ul#menu li span.active").css("opacity","1");
$("#nav ul#menu li span.active").hover("opacity","1");[code].....
It's the part of the code beneath the comment CONDITIONALS BELOW that I want to be able to only trigger it if span is not set to class .active.
View 1 Replies
View Related
May 25, 2011
I have a question here. I have 2 videos and if I click the image which uses #usemap, it will switch to the specific videos I clicked. FF and chrome has no problem but only IE.
The scenario is like this: Actual scenario is when the page load, it will display tab 1, video 1 and tab 2 is greyed out. If I clicked on tab 2, tab 1 is greyed out and video 2 is display. Both tabs I use #usemap.
But now the problem in IE is that it keeps on displaying tab 1 and video 2 instead of video 1 and when I clicked tab 2, tab 2 is selected but no video is loaded. Below is a simple code which hope it can helps better understanding of what I'm trying to do:
<div>
<img src="tab.jpg" id="tab1" #usemap="videotab">
<img src="tab.jpg" id="tab2" #usemap="videotab">
</div>
<div id="video1" style="display:block"><"1st video source codes here"></div>
<div id="video2" style="display:none"><"2nd video source codes here"></div>
[Code]...
IE just keep displaying video 2 when page load and video doesn't loads when tab 2 is clicked. Even if I program the 2 divs to be show, it only shows video 2 and video 1 is nowhere to be seen. And I tried taking out the video 2 codes, video 1 then can be seen.
View 3 Replies
View Related
Nov 27, 2011
I'm working on a script that will take the selected div and add an input to it.
If the div id="3" then when I alert it it works right but if the div id="post_3" then I get an alert of "object HTMLdivElement"
The javascript is simple(so far)
function create_reply_input(post_id){
alert(post_id);
}
And here's the php i'm using to populate the page with the posts
<li><a href='javascript:create_reply_input(post_$div_id);'>Reply</a></li>
View 1 Replies
View Related
Aug 19, 2011
I have a signup form on my site..when the user clicks the signup button, I am using a little script to check the form and make sure it's filled out correctly. I know i'm calling the script right because I did some error checking/debugging but it isn't actually doing its job.
Further more, I tried a quick alert to see the value of my variable, returned and I get an alert that reads "[object nodes list]".
Here's my script
<head>
<script type="text/javascript">
function chk_Empty(){
alert("working");
[Code]....
View 4 Replies
View Related
May 10, 2010
This is a makeshift sort function for a table. I want to replace a div contents with a javascript function call. It works fine if I define the individual case, but the general case doesn't work. The problem lies with the +divHold+ part. It never converges to the passed value on the 2nd iteration. This is my Div:
[Code]...
View 4 Replies
View Related
Jul 23, 2005
I'm having problems getting my popup menu to work correctly. I have the following script:
[Code] .....
View 5 Replies
View Related
Jan 21, 2010
I got a pice of html that i want to transform to UI Tabs. This code is aouto generated and wrong, so I want to correct it before calling tabs() function
<div id="localtabs" class="list">
<ul>
<li id="tab1"><a href="#tone" title="Local Tab One"><span>Local Tab One</span></a></li>
[Code].....
My target is to move the divs currently inside the UL tags outside.
My thought was to select the divs with this statement:
var tabdivs = $('#'+options.id+' ul').children('div');
alert('tabdivs.length '+tabdivs.length);
This works fine in Firefox he told me tabdivs.length 2 but in IE6 i got an alert tabdivs.length 0 .
Why IE6 found no childrens?
View 3 Replies
View Related
Apr 27, 2010
I'm looking for some guidance on a part of some coding practice I'm stuck on!
I've created a shopping cart using javascript, the items save to the arrays etc and it all works fine. If the user adds the same product again to the cart the quantity is added onto the previous quantity that is already in the cart.
To check if the item is already in the cart I've ued the below code, but what it does is update the quantity for the first cart, and when it updates the quantity for the second item it updates the quantity but keeps adding the same product to the cart in seperate elements of the array as well (if that makes sense?
here are the two functions used [code]...
It may jsut be a simple mistake I've made but it's been bugging me a lot and I can't seem to fix it.
View 2 Replies
View Related
Nov 17, 2011
I am sorry if this is a stupid question. I have never really used javascript before. I found some code online that I tried to piece together so I might not even be going about this the right way.
I want the background to take up 100% and resize with the browser. That works fine. I also want the text "welcome to the ahi life" stick to the bottom left hand corner and the enter button to stick to the bottom right. I would like these to resize with the browser as well. It all kind of works, except the first time you load the page the text and the button are much smaller than I would like them to be. If you refresh the page everything is correct.
[Code]...
View 4 Replies
View Related
Sep 9, 2009
I have a page with a textbox that I want to have a message written inside it that will dissapear when the user clicks in the text box and writes something and it will show up again if the user clicks somewhere else but hasn't written anything inside the textbox. So I am using the onfocus event in order to write "Enter your email here" and the onfocus event in order to show the "Enter your email here" message inside the textbox if the user clicks somewhere else in the webpage but has left the textbox blank. If however the user has written, for exampl "jim@yahoo.com", I want this to remain in the textbox.What am I doing wrong?
Code:
<html>
<head>
[code]....
View 2 Replies
View Related
Mar 13, 2010
If you look at this page [url] you will see that if you hover over the photo the text block goes up, and if you hover over the text it slides down and covers the photo. It's all pretty basic and it works fine. But ones I try to get them animated during the sliding up and down the trouble starts.
It works fine if you take the time and wait for them to go back to their starting position, but if you move over the items quickly it becomes a mess. You can see what I mean on this page [url]
I hoped that by adding a stop() before the animation if would fix the problem, but it doesn't really improve at all. It still quickly becomes a mess if you hover from one item to the next one.
How I could get the animations to work properly without it becoming a mess? I now there are double id's in the html, but unfortunately I can't really change the html.
View 1 Replies
View Related