Creating A Sentinel Loop?

Nov 7, 2010

i was assigned this task(see attached), but for some reason I'm having trouble getting it to work, i don't know if my problem is in the algorithm or if I'm using the wrong structures to solve the problem.

[Code]...

View 2 Replies


ADVERTISEMENT

Use An If-else Statement Within A Sentinel Controlled Loop Plan?

Jan 24, 2011

I am attempting to set up a very basic menu to drive a program for two different games. I need the menu to process using a primed sentinel controlled loop (where the quit option is the sentinel). I have already set up a function for each game and was hoping to call the function when the user selects a game. I also want to both (a) keep a count of the number of games played and (b) keep a points score, which is to be displayed before the menu is shown agin. When the user quits, I want the final number of points and games played written to document body. I have only very basic knowledge of JavaScript so I realise this is probably a simple answer but I've spent a heap of time on it so far and the menu still has glitches.

This is what I have so far:

SENTINEL = 0;
MESSAGE_MENU = 'Menu: 1. Pattern Game, 2. Guessing Game, 0. Quit'
userInput = parseInt(prompt(MESSAGE_MENU));
while(userInput != SENTINEL) {

[Code]....

View 1 Replies View Related

Creating Textboxes In Loop?

Dec 22, 2009

The idea here is to have a function in javascript that would take the value from one input box (lets call it txbA) and use it as the limit for a while loop or for-next loop and create a series of input boxes each with a unique name so that its value (when entered or changed)could later be used in other calculations.

When I try something like:

function MakeMany()
{
var y=parseInt(txbA.value);
for(var x=0;x<y;x++)

[Code]....

You can call this from a button and get the text boxes, but how do I get them to have unique names such as MMtb1, MMtb2, MMtb3 etc. ??

View 2 Replies View Related

Dynamically Creating An Array In A For Loop?

Apr 21, 2011

I am trying to create a function that creates an array comprised of filenames based on a given range. I.E if 2-8 is selected and a foldername of UMCP/ and a common name of college is also given, the function should return and array such as [UMCP/college2.jpg,UMCP/college3.jpg.....UMCP/college8.jpg]. Here is what I've got but the alert that should tell me the filename of the first image says it is undefined, how can i fix this?

function getArrayPhotosNames (total,count,first,last) {
/*window.alert("get Array Photo Names");*/
var folderName = document.getElementById("photofold").value;
var Alias = document.getElementById("commonName").value;

[Code]....

View 14 Replies View Related

Creating A For Loop To Detect How Many Selects Are On Form

Jul 23, 2005

On my form i have multiple select which all have an id value total1, total2,
total3 etc so i am trying to detect how many there are and then use this to
caculate a total.

Is there a javascript reference to basically go to a form and produce a loop
which will show me how many select drop down boxes there on a form.

Or would i have t use something like

for (var i=0; i < frm.elements.length; ++i) {
form.elements.length
form_field = frm.elements[i]

and then have a nested if to detect if it is select value or has an matching
value ..

View 7 Replies View Related

JQuery :: Creating Multiple Objects In An Each() Loop?

Sep 16, 2011

I have to stuff multiple objects in global var populated in a foreach loop and seperated by a comma.The loop is:

// GlobalG.objects;
$('.class').each(function() {
var title = $(this).text();
var src = $(this).attr('src');

[code]....

View 2 Replies View Related

Creating HTML Table, Loop Not Triggering?

Aug 4, 2010

I am trying to create a simple HTML table with the squares of numbers and for some reason the loop is not triggering.

Code:

<table border="1">
<tr><td><h2>Table of Squares</h2></td></tr>
<tr><td>
Number

[Code]....

When I run the page all that comes up is the start of the table that is written before the script executes. Also is there any way I could use a debugger to catch this on my own? I tried the firefox debugger but it didn't catch anything when I ran it through, maybe I was just doing it wrong.

View 2 Replies View Related

Creating Massive Grid With Loop Without Freezing?

Oct 14, 2011

I have been struggling with a loop of mine. The loop should create a grid, of 204,000 squares(div's). And the total would create a grid field of 340 pixels by 600 pixels. All div's are sized 1 pixel.The idea is to create a grid, that shows temperature data in a gradient style, like a weather heat map. The data is collected from temperature sensors which are connected to a database.The only problem is that because it's such a massive amount of calculations to be calculated by javaScript, the whole thing freezes. Here is a sample of my code:

Code:

function makeGrid()
{
for (var i = 0; i < 8160; i++)
{

[code]....

Another problem is, the grid should be reloaded every 5 seconds or less.Because that's the interval used by the temp sensors, and for the usage that's planned for the project, its really important that the data is constantly up to date. using another web based language are welcome, as long as they are combinable with PHP or AJAX. Or maybe there is a ready to use library that I dont know of. Couldn't find anything for jQuery.

View 6 Replies View Related

JQuery :: Show / Hide And Fade In Animations - Creating Loop

May 13, 2009

I have several elements that I can perform show hide and fadeIn animations on but I want the action to continue on an endless loop. Is this possible? If it is, are there any cpu usage issues when using a loop?
<script type="text/javascript">
$(document).ready(function(){
$(".upright").hide(300);
$(".cntrlg").show(300);
$(".cntrlg").hide(300);
$(".cntrmed").show(500);
$(".cntrmed").hide(300);
$(".cntrlg, .lowleftmed").show(100);
$(".cntrlg, .lowleftmed").hide(100);
$(".lowrightmed").show(300);
$(".lowrightmed").hide(300);
$(".cntrmed").show(300);
$(".cntrmed").hide(300);
$(".upright").show(2000);
$("#dai1").fadeIn(3000);
$("#dai2").fadeIn(3000);
$("#dai3").fadeIn(3000);
$("#june1").fadeIn(3000);
$("#june2").fadeIn(3000);
$("#june3").fadeIn(3000);
});
</script>

View 8 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

JQuery :: Loop Forever And Reload Xml Each Loop?

Jul 29, 2011

I have the code below, how could it be modified to loop over and over and reload the xml file each time. Flow would be: load xml, run thruogh code to display each xml node one at a time, when reach last node, start all over, reloading xml file,

[Code]...

View 2 Replies View Related

While Loop Or For Loop For This Script Involving Arrays?

Mar 6, 2011

As you can see from the code and the output, it will attempt to write to the browser how many moves, but only '0'.

function rollDie()
{
return Math.floor(Math.random() * 6) + 1;
}
/*
*searches for a number in a number array.
*
*function takes two arguments[CODE]...

View 5 Replies View Related

Changing For Loop To While Loop?

Nov 12, 2010

I am doing some studying and we was to create a small loop using either the for loop, while loop or do while loop. I chose to do the for loop because it was easier to understand, but I want to know how to do the same using the while loop. Here is the for loop I have, but I cant figure out how to change to while loop.

for (var i = 0; i < 5; ++i)
{
for (var j = i; j < 5; ++j)
{

[Code]....

How do you make the same using a while loop?

View 2 Replies View Related

For Loop Wont Loop?

Jul 5, 2010

it wont loop,as long as you enter something in the name field it will submit. also how do i stop from submitting if all fields are not filled out?

function checkForm(form)
{
var len = form.elements.length;[code]....

View 3 Replies View Related

Creating A File

Jul 23, 2005

It there another was to do this
var fso = new ActiveXObject('Scripting.FileSystemObject');

Im trying to run a javascript file automatically, but it complains that I
have to say YES to Active X.

View 1 Replies View Related

Creating Script On The Fly

Jul 31, 2005

I have a problem getting the following simple example
of "document.write" creating a script on the fly
to work in all html browsers.

It works in I.E., Firefox, and Netscape 7 above.
It doesn't seem to work in Netscape 4. Am I missing
something with it? When I look at page source in
Netscape 4 the script isn't even shown. Code:

View 7 Replies View Related

Creating A 'help' Function

Sep 29, 2007

I'm trying to create a function in JavaScript using Dreamweaver8 such that when a user hits the ' F1' key when a text box is selected a separate "pop-up" window will open, with text of my choice.

Does anybody have any pointers or even some source code? I use ASP on my server.

View 12 Replies View Related

Creating Variables On The Fly

Jul 20, 2005

how you would piece
together a variable name and then assign it a value. I want to create a
hidden field and assign it a value based on the value of another variable

Right now it looks like:

("document.all.SM_MARK_10" + dateNumber + ".value")

where dateNumber is an already defined integer. What I want is to say

document.all.SM_MARK_1001.value="XX"
document.all.SM_MARK_1002.value="X2"

etc.

based on that value of dateNumber. Any way to do this easily?

View 22 Replies View Related

JQuery :: Creating A New Tag?

Sep 23, 2009

How do I create a new tag with jquery? I tried something like this:

link = $('a').attr({
class: 'logoLink',
target: '_blank',
href: 'http://www.someurl.com/'
});

And then appended it to another image, but this added every link that already existed on the page.

View 3 Replies View Related

Creating A Class With Just It's Name?

Jun 27, 2010

rote a bunch of Javascript classes for this framework I'm working on and want to be able to create instances of the class using just it's name string. For example: Given the following class

javascript Code:
Original
- javascript Code

[code]....

View 4 Replies View Related

Creating Error Pop-up Box In JS

Sep 30, 2010

I am writing a function that alerts a user that they did not enter a password what change do I need to make to this code to correct my issue it isn't doing anything.

View 2 Replies View Related

Creating A Less Than Or More Than Calculator?

Dec 2, 2011

I have the last assignment that she wants us to do and I had to pull up another assignment that she wanted us to build upon( which is one of those coding without anything advance)

<html>
<head>
<title>

[code]....

now she wants us to do max <beta and then name the variables with if a<b and I don't know if I put that in the concatenation or what to name my variables!

View 18 Replies View Related

Creating Table In JS?

Aug 17, 2010

i am fairly new to JS for which i am working jQuery but that is for later.right now i am not getting my table printed out when i put input type="text".

here is my code

[Code]...

moreover i m writing this code to later call in a dialog box. using jQuery. but for now why isn't my code being printed with input type. do i have escape "" inside "" like in php? can i make more hierarchy type html in JS, i see when i put the td in next line the code doesn't execute. i guess white spaces have some significance in JS?

View 1 Replies View Related

Creating Hotkeys...

Aug 21, 2003

is there a way to create a hotkey in JavaScript? ie) hit the 'v' key on the keyboard and it calls a function...

View 5 Replies View Related

Creating A Script

Nov 3, 2004

I need some help creating a script. Forgive me for posting this in multiple forums, as I first posted this in the php forum, but I know it can be done with a client side javascript as well. So here goes. I need to create a form where I can paste a list of domain names, click submit (or even just on mouseout, etc.), and have the script then return me to a page (or update a select field on the same page) with the domain names formatted within html code hyperlinking to the name.
For example, if I were to paste a list of

domain1.com
domain2.com
domain3.net
domain4.net
domain5.biz
etc.com

then click submit (or move my mouse out, [we're talking javascript here, right...]),
it would return the following results, ready for me to then paste into my webpage:

<a target="whatever" href="http://domain1.com">domain1.com</a><br>
<a target="whatever" href="http://domain2.com">domain2.com</a><br>
<a target="whatever" href="http://domain3.net">domain3.net</a><br>
<a target="whatever" href="http://domain4.net">domain4.net</a><br>
<a target="whatever" href="http://domain5.biz">domain5.biz</a><br>
<a target="whatever" href="http://etc.com">etc.com</a><br>

View 1 Replies View Related







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