/    Sign up×
Community /Pin to ProfileBookmark

script problem

im working on a javascript project at the moment and im having a few problems.

for some reason the page never seems to full load (from what i guess meaning a neverending loop) which i cant find.

also on the loops containing DIRECTOR i never get any results which i cant understand atall when the exact same script works on the FILM_YEAR and gives results.

thanks in advance

[CODE]
// global variables to freely use
var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
var results;
var FILM = new Array();
var FILMA = new Array();
var FILMB = new Array();
var FILMD = new Array();
//loop the list of directors
function director()
{
for (i=0;i<DIRECTOR.length;i++)
{
document.write(“<option value=”+DIRECTOR[i]+”>” + DIRECTOR[i] + “</option>”);
}
}
//loop the list of film dates
function filmdate()
{
for (i=0;i<FILM_YEAR.length;i++)
{
document.write(“<option value=”+FILM_YEAR[i]+”>” + FILM_YEAR[i] + “</option>”);
}
}

//function to check if the year matches the entered data
function checkvalues()
{
formdirector=document.filmsear.formdirector.value;
formyear=document.filmsear.formyear.value;
n = 0;
document.write(“<h1>Matching Films For Year:</h1>”);
//loop through the years and check if any results match if they do
//assign DIRECTOR[i] TO FILMD[i] so only the valid years are stored in the array
for (i=0;i<FILM_YEAR.length;i++)
{
if (FILM_YEAR[i] == formyear)
{
FILMD[i] = DIRECTOR[i];
FILMA[n] = FILM_YEAR[i] + ” | ” + FILM_TITLE[i] + ” | ” + DIRECTOR[i];
document.write(“<p>” + FILMA[n] + “</p>”);
n = n++;
}
}
n = 0;
document.write(“<h1>Matching Films For Director:</h1>”);
//loop through the directors and check if any results match.
for (i=0;i<DIRECTOR.length;i++)
{
if (DIRECTOR[i]==formdirector)
{
FILMB[n] = FILM_YEAR[i] + ” | ” + FILM_TITLE[i] + ” | ” + DIRECTOR[i];
document.write(“<p>” + FILMB[n] + “</p>”);
n = n++;
}
}
n = 0;
document.write(“<h1>Matching Films For Year and Director:</h1>”);
//loops through the new array of the matching years and checks if they match the directors name then write the results
for (i=0;i<FILMD.length;i++)
{
if (FILMD[i] == formdirector)
{
FILM[n] = FILM_YEAR[i] + ” | ” + FILM_TITLE[i] + ” | ” + DIRECTOR[i];
document.write(“<p>” + FILM[n] + “</p>”);
n = n++;
}
}
}
[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @knowj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...