/    Sign up×
Community /Pin to ProfileBookmark

Changes not recognized

My company currently lacks a JavaScript author, so i’m trying to figure this stuff out as a web designer (who knows html & css). I’ve been able to edit these files successfully in the past, but for some reason the changes i make are no longer working and i don’t know enough about JS to determine why.

on one of our product pages we have a drop-down “selection” form that asks a few questions to determine which product is best suited for the user. In the JS function there’s an array with a series of on/off markers that translate to yes/no for the corresponding client-side form choices. Products 0-9 work as intended but 10 and 11 are not. They remain staticly displayed on the page.

here is the .js file

[CODE]var speaks = null;

function initSpeaks()
{

speaks = new Array(23);

speaks[0]=”xxx.xx…xSRM150″;
speaks[1]=”xxxxxx…xSRM350″;
speaks[2]=”xxxxxxxx.xSRM450″;
speaks[3]=”xxx.xxx..xSWA1501″;
speaks[4]=”xxx.xxxx.xSWA1801z”;
speaks[5]=”xxx.xxxx.xSWA2801z”;
speaks[6]=”xxxxxx..x.C200″;
speaks[7]=”xxxxxxxxx.C300z”;
speaks[8]=”x.xxxxxx.xHD1521″;
speaks[9]=”x.xxxxxx.xHD1531″;
speaks[10]=”xxx.xx…xTH15A”;
speaks[11]=”xxx.xx…xTH18S”;
}

function DOM(n)
{
return document.getElementById(n);
}

function showMatches()
{
if ( speaks == null )
initSpeaks();

var spk_use, spk_audience, spk_amp;

spk_use = DOM(“spk_use”).value;
spk_audience = DOM(“spk_audience”).value;
spk_amp = DOM(“spk_amp”).value;

if ( spk_use == 1 )
{
DOM(“spk_audience”).disabled = true;
DOM(“spk_audience”).selectedIndex = 0;
}
else
{
DOM(“spk_audience”).disabled = false;
}

var i;
for ( i = 0 ; i < 23 ; i++ )
{
var nm = “st_” + speaks[i].substring( 10, 255 );
var o = DOM(nm);
if ( o == null )
{
// alert(nm);
continue;

}

if ( speaks[i].substr( spk_use, 1 ) == ‘x’ &&
speaks[i].substr( spk_audience, 1 ) == ‘x’ &&
speaks[i].substr( spk_amp, 1 ) == ‘x’ )
{
o.className = “rotate”;
}
else
{
o.className = “rotate_off”;
}

}
// hide SRM450 for mains in large audiences
if ( spk_use == 4 && spk_audience > 5 )
{
DOM(“st_SRM450”).className = “rotate_off”;

}
}

// JavaScript Document

//<![CDATA[

function DOM(n)
{
if (document.all) return(document.all[n]);
if (document.getElementById) return(document.getElementById(n));
return(null);
}

function toggleDisplay( n )
{
var o = DOM(n);

if ( o == null )
return;

o.style.display = (o.style.display == ”) ? “none” : “”;
}

function hide( n ) {
var o = DOM(n);

if ( o == null )
{
alert(n);
return;
}

if ( o.style.display == “” )
o.style.display = “none”;
}

function show( n ) {
var o = DOM(n);

if ( o == null )
{
alert(n);
return;
}

if ( o.style.display == “none” )
o.style.display = “”;
}

function showpanel( n ) {

hide(“panel_default”);

hide(“panel_srm150”);
hide(“panel_srm350”);
hide(“panel_srm450”);
hide(“panel_hd1521”);
hide(“panel_hd1531”);
hide(“panel_swa1501”);
hide(“panel_swa1801z”);
hide(“panel_swa2801z”);
hide(“panel_c200”);
hide(“panel_c300z”);
hide(“panel_th15a”);
hide(“panel_th18s”);

show( n );
}

//]]>[/CODE]

i’ve tried a few things based on guesses but nothing worked. if someone could tell me how to fix i would be very happy.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@kristinachildsauthorNov 03.2009 — 44 views and no comments... *chuckle* i thought for sure someone would have insight.

did i not post enough information or is this just stumping some folk? i suppose now i don't feel so utterly retarded.
Copy linkTweet thisAlerts:
@javawebdogNov 04.2009 — Why are you fixing the array 'speaks' to 23 elements?

If you leave it out the array is less limited.

Instead of using for loops like:

var i;

for ( i = 0 ; i < 23 ; i++ )

you could use a

for (i in speaks)

and avoid use of a fixed array length.

Do you have an accessible web page with the functionality so we can see it as a whole?
Copy linkTweet thisAlerts:
@kristinachildsauthorNov 04.2009 — http://www.mackie.com/products/speakers/index.html

i did not design or build this website, i simply maintain it and add new pages/products... and i certainly didn't author this script, so am unable to answer "why" questions.

i /believe/ at one point there were 24 products, so whomever changed it last probably removed the list of products and didn't change the number? i'm not entirely sure.
Copy linkTweet thisAlerts:
@kristinachildsauthorNov 04.2009 — i should add that i don't really know anything about javascript. i can hack simple scripts, but this is above my skill level. i just need to hold out long enough for our new developer to start...
Copy linkTweet thisAlerts:
@javawebdogNov 04.2009 — I believe I may have located your problem, that is, it works for 0-9 but not 10 or 11 (the value passed to showMatches() using an onChange event).

If you review the code snippet below (taken from your web page) you will see that the <option value="[I][COLOR="Red"]<an integer>[/COLOR][/I]">

in the selects range from 0 to 9, but at no time are the values 10 or 11 passed to the function showMatches().

No parameter sent, no change.

Hope that helps.

[CODE] <td width="243" valign="top" bgcolor="#595959"><div style="padding:0px 12px 15px 12px;color:white;">
<div class="selector_title"><img src="images/som_application.gif" border="0"></div>
<div class="selector_small">As mains or monitors? On poles or flown?</div>
<select class="selector_drop" size=1 id="spk_use" onChange="showMatches();" style="width:185px;color">
<option SELECTED value="0">All</option>
<option value="1">Stage Monitor</option>
<option value="2">Pole Mount</option>
<option value="3">Flyable</option>
<option value="4">Mains</option>
</select>
<br>
</div>
<div style="background-color:#6A6A6A;padding:10px 12px 15px 12px;color:white;">
<div class="selector_title"><img src="images/som_audience.gif" border="0"></div>
<div class="selector_small">A garage? A night club? A festival? The MegaDome?</div>
<select class="selector_drop" size=1 id="spk_audience" onChange="showMatches()" style="width:185px">
<option SELECTED value="0">All</option>
<option value="5">&lt; 200</option>
<option value="6">201-400</option>
<option value="7">400+</option>
</select>
<br>
</div>
<div style="padding:10px 12px 0px 12px;color:white;">
<div class="selector_title"><img src="images/som_design.gif" border="0"></div>
<div class="selector_small">"Active" speakers have the amps and processing built-in. "Passive" designs let you use your own.</div>
<select class="selector_drop" size=1 id="spk_amp" onChange="showMatches();" style="width:185px">
<option SELECTED value="0">All</option>
<option value="9">Active</option>
<option value="8">Passive</option>
</select>
</div></td>[/CODE]
Copy linkTweet thisAlerts:
@kristinachildsauthorNov 04.2009 — those value integers directly correspond to the array "x" "." deliminators. "x" essentially means "on" and "." means "off," thus the value integer referring back to the array.

they have no bearing on the number of active products in the list.
×

Success!

Help @kristinachilds 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.28,
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,
)...