JQuery :: Figuring Out - Use A Conditional Statement If Children Exist?
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:
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:
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:
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]
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
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.
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?
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.
I'd like to be able to know, in javascript, if the media that's rendering is screen or print. I have no nefarious purpose here (I've often seen people wanting to do this to prevent printing): I have a report that uses javascript to page 20 items at a time and I want it to show all items at a time when printing.
- I can make it more or less work on IE using onbeforeprint, but no luck on better browsers
- When the page first renders the combination of @print and @screen styles work good, but the moment javascript hides stuff it stays hidden (because it's changing the element.style attribute of the rows.
- I've tried figuring it out by having an element with different styles declared in the @print and @screen rules of the stylesheet, but I can't make it show any difference to the javascript being executed (e.g. changing the position of this element for print and screen, the element's position is always what is first calculated for the screen).
I want to start out by entering an investment amount as well as an interest amount. Then I want to find out how many years it would take to become a millionaire, using each cycle through a looping statement as one year. What would be the best way to do this?
I am dynamically creating CheckBoxes DropDoenlist with certain set of values of not all of then are created any time.But in Script i want to get sure whether that element has been created or not. So how can i check for radio button list and dropdown list.Below is the code for my dynamic list creation:
I have two multiple selects on my page. One gets updated via ajax whenever the user filters data (we'll call that select "#select-1"), when they select options from that it then gets moved into the other select (we'll call that "#select-2"). That is all working fine but I'd like to refine it so that they can't select the same data twice.
So, basically, what I'd like to do is add logic within the ajax call to only update the select options in (#select-1) if it does NOT exist in the other select (#select-2).
I have no clue where to even begin with this....do I need to store the val's in an array and then search for each one in the other?
I have a page with two divs on it, <div id="left"> and <div id="right"> . On my page, there are times when the right div is not displayed as there is no content in it, how can I get jquery to detect that div id="right" does not exist on a page so make the width of the left div to 1200px.
This is what ive found, but im not sure length is what I should be using to calculate if a div exists or not:
In the examples for live() and delegate(), the selectors match at least one element that already exists. Will either of these commands work on elements for which there is no match at all on page load?
In my case, I want to bind a keyup event to the textareas that jeditable creates. I could probably create custom plug-in (to the plug-in :) to do the job, but I'd like to use live or delegate if they would work.
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
I am trying to run 2 different scripts on a page, both of them work fine independently, however, when both of them are running, one of them refuses to work.
This is the page: [URL]...this is what the client wants!!) The menu on the left is supposed to have a flyout element, but that doesn't work when the falling leaves are working.
This is the menu script: startList = function() { if (document.all&&document.getElementById) { navRoot = document.getElementById("nav"); for (i=0; i<navRoot.childNodes.length; i++) {
I have a script that will set the focus to a particular input box. I want the script to check to see if the input box exist also.
I'm receiving the following error: 'document.ScheduleForm.txtGrossPayroll99' is null or not an object.
The txtGrossPayroll99 is a field that does not exist. I've hard-coded this name into the script to see if it is working correctly. I'm using the OnLoad event inside the <Body> tag to execute this function.
var formInUse = false; function setFocus() { if ((!formInUse) && (typeof(document.ScheduleForm.txtGrossPayroll99) != "undefined") && (typeof(document.ScheduleForm.txtGrossPayroll99) != null) );{ document.ScheduleForm.txtGrossPayroll99.focus(); }}
Let's say that I have generated var SomeVariable = true; from server. On client side I have:
if (SomeVariable == true) { do something }
How could I first check if my variable is undefined? Or how can I say if some exception occures please don't report error, just continiue? If variable is not generated from server, it will report me an error..
I am making a form where you can either upload images or link images and upload a video. The problem is that I want a or situation. I made javascript function that when you click one of the 3 images it will add in one item this could be a image link or uploaded image or a video. There is only one function that runs and inside that function has if statements to figure out which one image was clicked.
I have 3 images one is for image links one for uploading images and one for uploading video. the problem is that I want the user to append only image links and uploaded image or uploaded video.
I am only allowing 8 images to be uploaded or 1 video. This is a form that submits a message with either of the above but I only want to append only the images or the video but not both.
We have a JSP website intended for viewing with IE 5 (and above) On a certain jsp page, there are few span objects (<SPAN ID="name">text</SPAN>), which are created dynamically.
The spans share the same ID, so we are able to reference them as an array, in the javascript code : for example:
It may occur, since these spans are created dynamically by the JSP page, that on a certain instance of the page, no spans are created.
My question is - how do we know, in the JS code, that no spans of ID 'wow' exist? We tried several ways:
if (!wow) alert('no wow'); // If there were no spans, this gives a js error
tried a few other methods which i cant recall of now.. I know of a workaround - to add a 'dummy' span with the 'wow' ID , but I prefer to know if there is a better way to deal with this.
When i select a file (through html file control) from local machine, before uploading i want to check if the selected file exist(because,after selecting and before submitting the form,user may change the name/delete the file from the source). so after selecting the file, i need to check the same file exist as it is using javascript/ajax. Back end is JSP.Eg: Am selecting abc.jpg from my system and changing the file name form the source as abcd.jpg, now abc.jpg does not exist. But i want to check if exist. If selected file does not exist, i want to display a message before uploading/submitting the form.
var myarray=new Array(4) for (i=3; i <7; i++) myarray[i]=new Array(8); for (i=3;i<7;i++) {
[code]...
Here is my code and i want to check if the cell exist and if it is true to take the content of the cell. But it gives me an error in the 6 line(which i believe is wrong):
Message: Object doesn't support this property or method