Loop Function Not Working - How To Make It Work

Jun 8, 2009

I have a pretty simple function set up to pull XML data into my page, but there's a couple things wrong with it. I'm REALLY new to J Script and really trying my best to learn, but for some reason I'm not yet adept at googling the right results :rolleyes:At the very bottom you can see the data from the first XML entry, so it seems the function itself is working fine, but it's not looping coorectly to access all the data.Also, I want to pull it into the "shows" div of the page, but can't figure out how to put it there (seriously, I am very new with JS). The code below is not working, but the live site has it added to the body, which does show the one entry.Here's the XML function, the XML data and the HTML markup:

Shows function -

function loaddates()
{
var xmlData = document.getElementById("tourdates");
var newDates = xmlData.getElementsByTagName("dates");

[code]...

View 4 Replies


ADVERTISEMENT

For Loop Not Working - How To Make It Work

Jul 17, 2009

Why wont my for loop work it wont alert the var images1....

<script type="text/javascript">
for(i=1;i<6;i++){
images[i] = "no"+i+".jpg";

[code]...

View 2 Replies View Related

Alert Function Not Working - How To Make It Work

Apr 10, 2010

Code:

<script>
var timer = 0;
function SpellItOut(word)
{

[code]....

View 3 Replies View Related

Onmouseout Not Working - How To Make It Work

Jun 9, 2009

I have a webpage with addition questions for numeracy training. I am storing the sums in a table(id="sums"), with an empty textbox(id=ans1) for the user to type the answer. After the user types an answer and moves onto the next Q, I want to activate a popup dispaying if the answer is correct or not. I am tackling this with onmouseout. The script checks the answer, then displays a confirm message if correct or and alert message if wrong. The onmouseout is not working

Code:

input type="text" name="ans1" size="1" maxlength="2" id="ans1" onmouseout="checkAns1();"

Code:

function checkAns1(){
if(document.sums.ans1.value==(document.sums.Q1R1.value + document.sums.Q1R2.value)){
var confirm("correct");

[code]....

View 14 Replies View Related

Stickies App Not Working - How To Make It Work

Mar 19, 2009

I must have a syntax error, because this function crashes the entire script (even the other functions).

function newNote()
{
allNotes = document.getElementById('notes-stickies-app').innerHTML;
secondadder = 1;

[code]...

EDIT: to get to the stickies part, click the apple menu, and click stickies. you'll see how the stickies wont drag because this script that adds new stickies has a problem.

View 2 Replies View Related

GetElementById Not Working - How To Make It Work

Dec 27, 2010

This seems like a total beginner thing, but I don't know why it isn't working. I'm working from examples from a sitepoint pdf. Here's my html:

Code:

<body>
<h1 id="stupid">sdfasd</h1>
<p>sdjfa</p>

[code]....

When I run an if statement, I'll get an alert letting me know that the value of target is null, but why is it null? It should contain a reference to the h1 node.

View 4 Replies View Related

External 'Login' Not Working - How To Make It Work

Jan 9, 2011

below is the script I'm trying to externalize but whatever I've tried doesn't work (the Login button doesn't nothing when the script is external).

<form name="login" autocomplete="off">
<p>User Name :
<input type="text" name="username"></p>

[code]...

View 5 Replies View Related

Logical Operator Not Working - How To Make It Work

Jul 14, 2010

What kind of logical error am I making? I want the alert(); to execute if both of the variables (cjob and czip) are blank, but the only way I can get it to work is if I replace && with ||.

if(trim(cjob.value) && trim(czip.value) == '')
{
alert('Hello');
}

View 2 Replies View Related

Onmouseover Function Inside For Loop Not Working?

Apr 3, 2010

I have a simple HTML page with one DIV element with the id "rotator". Inside that, JavaScript is supposed to create boxes that react to mouseovers.

The weird thing is: The whole script works, but ONLY on the LAST box I create, no matter what I do. I can manually add the mouseover code to any one of these boxes, but it will only take on the last one. I can have JavaScript tell me the mouseover status of each box, and they all tell me they have code assigned correctly - but again only the last one works...

Here's the relevant code (yes, highly abbreviated, but it's the part that fails on me):

var maxBoxes = 10;
function initSite() {
var rotator = document.getElementById("rotator");
rotator.innerHTML = "";

[Code]....

initSite is called in the body onload. All kinds of other animation parts are implemented that work fine, just this mouseover won't work. I have tried re-writing it in multiple different ways, including "xyz.onmouseover = myMouseCode" and then defining the function separately later - still no dice.

So, the code creates 10 boxes (0-9) and 10 boxes that are on top of them to create a form of shadow effect depending on the position of the original boxes. Since the "myDark" boxes are on top of the "myBox" boxes, I apply the onmouseover onto the "myDark" boxes, but it only works on "myDark9" and no other box. They are all created the same way, the mouseover assigned the same way...

View 8 Replies View Related

Function Loop Not Working - Finding The Alternative?

Jun 4, 2010

Here's the code:

for (var i = 1; i < 5; i++)
var pl = eval("player" + i)
var namepl = eval("document.charInput.name" + i + ".value");

[code]....

In the case of the 2nd-4th player, it changes to name2.value, etc.Based on these three inputs, I need to iterate through all four players and make the player object for each of them, as I've done above.

View 5 Replies View Related

JQuery :: Make A JS Function Work As A Link?

Oct 17, 2010

I'm new to jQuery, but learning fast, and loving the new functionality!I'm using a Flash upload component that all works fine, and once it's complete (file uploaded) it calls function.I'm running the Flash upload in a modal (nyroModal - very cool!). The link below does what I need it to do - navigate to a new page and re-size the modal:<a href="test2.aspx#blabla" class="nyroModal">Ajax Filtering Content #test</a>What I need to work out is how to make the JS function above work in the same way as this link. I know very little JS, but I think the 'class="nyroModal" needs to be part of the link in the function some how??

View 3 Replies View Related

JQuery :: Make A Function To Be Able To Change The InnerHTML Of That Div But It Didn't Work?

Jan 5, 2011

I don't really know how to say this, that's why I'm going to show you some code which will hopefully point out what I mean.This is what I wrote yesterday:

var div = $('<div></div>').attr('id','box').fadeIn(1250);
$('body').append(div);

This worked well, but then I wanted to make a function to be able to change the innerHTML of that div but it didn't work.

function changeContent(content) {
var box = $('#box');
box.html(content);

[code].....

View 2 Replies View Related

Game - Rock Paper Scissors - Make The Playagain Function Work

Apr 24, 2010

I have written a game of rock, paper, scissors. There are two things I would like to do here:

1. Make the playagain function work. I would like to have a variable start out as 'y', then be redefined as either 'y' or 'n' when the prompt occurs. If this is not possible, any other way to make this work would be welcome.

2. Use <div> tags and CSS to make .swf's appear and disappear accordingly.

EX: I say scissors, Computer says paper. An swf is played of scissors beating paper. When the anim is over, it disappears, and the game continues.

The Code:

Code:

View 3 Replies View Related

Make A Search Function Work In A Listbox Full Of Onchange Tags?

Jun 20, 2011

I've got this listbox full of hundreds of employee names. Clicking on a name executes a function using onchange. Because of the length of the list I decided a search function would be really handy and I finally found one that works.

Now the search function, when you type in the input box, scrolls the list to the first matching entry. And that's good, that's what I wanted.

The problem comes in when you try to click on the name the search function found. Nothing happens ofcourse because the onchange tag in the list reacts to changes, not direct clicks.

code:

The list is populated by java but for testing I disabled the function that clears the "Loading" option and I set it to selected. That way the loading option is highlighted by default and the search function is free to highlight something else, then when I click on the search result it works like it's supposed to.

But keeping a highlighted option at the top of the list for that sole purpose isn't very elegant, especially since if you click on it the onchange function tries to execute and generates errors. The only solution I can think of is to use java to generate another option way at the bottom of the list that has the selected attribute but I don't quite know how to do that.

View 1 Replies View Related

Change Window.onload Function To Make Script Work Before Website Loads?

Oct 29, 2009

The following javascript loads after the page loads. Is there a way to change this onload function and make it work as the page is loading?The javascript is meant for mousewheel scrolling for a horizontal website. The website I am using this for has a fixed width - 29000px

Code:
*/

window.onload = function() {
tinyScrolling.init();[code]...

View 3 Replies View Related

Recursive Function With For Loop, For Loop Is Breaking When Calling Itself

Jan 22, 2011

I have been looking at this code for two evenings now, and rewrote it 4 times already. It started out as jQuery code and now it's just concatenating strings together.

What I'm trying to do: Build a menu/outline using unordered lists from a multidimensional array.

What is happening: Inside the buildMenuHTML function, if I call buildMenuHTML, the for loop only happens once (i.e. only for 'i' having a value of '0'.) If I comment out the call to itself, it goes through the for loop all 3 times, but obviously the submenus are not created.

Here is the test object:

test = [
{
"name" : "Menu 1",
"url" : "menu1.html",
"submenu" : [

[Code].....

'Menu 2' and 'Menu 3' don't show up! I'm sure it's something small that I'm overlooking.

View 2 Replies View Related

Send A Loop Variable (i) To A Function Inside The Loop

Aug 4, 2011

I'm looking to send a loop variable (i) to a function inside the loop, but I can't seem to get it to use the value I want, it keeps making it a reference of i and therefore the function is always called using the last value of i rather than the one it was set with.

So if i have 5 Tabs then Tab 1, when clicked, should call DefaultTabClick(0) and so on rather than always using 4 for any of the tabs.

View 2 Replies View Related

Make The Slideshow Loop ?

Nov 25, 2011

Im using a slideshow on my website but it stops when he displayed all 10 images but i wanna make it loop.

Here is my script:

Quote:

View 1 Replies View Related

While Loop Does Not Work?

Jun 23, 2011

I want to perform a loop while the scroll height of a div is larger than the set height (this will be done for excerpts) however the loop doesn't work (I realize this would be an endless loop). Yet it works when I replace "while" with "if".

function scrollDetect(elemId) {
var elem = document.getElementById(elemId);
while (elem.scrollHeight > elem.clientHeight) {
alert('test!')
}
}
scrollDetect('pmessage');

View 9 Replies View Related

JQuery :: How To Make An Unfinished Loop

Aug 13, 2010

i am a beginner with jquery and im wondering how i can make an unfinished loop? i have some code written and i how can i make a loop which is running all the time since document ready.

for example i would change a background color for #block or slideUp this element. this would be also perfect if i could delay this actions and stop the loop on mouseover but this are the question for the future :)

[Code]...

View 1 Replies View Related

Make A Multiplication Table Using For Loop?

Jul 8, 2009

How can you make a multiplication table using For loop? I've been trying to make one, but still.. :(

Anyway, if you have one.. May I see how you do it? ( codes )

View 4 Replies View Related

Make An Array Inside A Loop?

Feb 10, 2011

I have this loop:

for (var j = 0; j < gmarkers.length; j++) {
gmarkers[j].hide();
elabels[j].hide();
map.closeInfoWindow();

[Code]....

which was useful for passing the p variable when it was just one number.

but now I need to get that number every time j gets set (I understand that the j gets overwritten each time the loop goes through).

What would be ideal is if p could become an array, the contents of which match the values that j has passed though during the loop cycle.

I thought var p = new Array (j); minght do the trick, but obviously not...

View 4 Replies View Related

JQuery :: How To Make Loop Wait For Event

May 27, 2011

I'm trying to make a list of tweets fade in and out progressively down the list. I'm pretty new to javascript and jquery, so I might be missing out on some basics.

1. How do I make the while loop infinite and loop around itself, because I'd like the tweets to loop around when it reaches the last tweet. I tried adding the if statement to make it go back to 0 but it hangs my page when I include it.
2. How do I make the loop not run altogether at once? I've tried queue() and putting in delay(4000) right before the .eq(n) so that it delays 4000ms before selecting the next tweet, but I'm trying to find a more elegant solution to it as the timing might be offset infinitely if there are changes in the timings.

var $j = jQuery.noConflict();
$j(document).ready(function() {
var tweet = $j('#twitter-3 .tweets li').length;
var n = 0;
while (n <= tweet) {
$j('#twitter-3 .tweets li').eq(n).delay(500).fadeIn(1000).delay(2000).fadeOut(500);
n++;
//if (n == tweet) {
// n = 0;
//};
};});

View 5 Replies View Related

Don't Make Functions Within A Loop Error From JSLint

Aug 30, 2010

I am working on a site and in the process borrowed some js from some one to get dropdown menus to work, but after a while got reports from people who tested my site of some problems and decided to verify all my code, and i have fixed most bugs but the one listed in the title.

sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {

[code]....

View 7 Replies View Related

Submit From But Doesn't Work In Php Loop

Sep 10, 2009

I want to submit form using javascript but as I see javascript doesn't work in php loop. I use this code:

<form name="theForm">
<input type=text name="formInput">
<a href="javascript:document.theForm.submit();">Submit</a>
</form>

and it works fine in ordinary page, but stops working in php loop! I need to use link, not button to submit form.

View 6 Replies View Related

Radiobutton For Loop Doesn't Work

Aug 1, 2011

I know I am doing this right but it just doesn't work. The condition for radiobutton that if it's not checked then an alert should display. But it won't work!

[Code]...

View 2 Replies View Related







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