...

View Full Version : cannot correctly modify menu-switching script(s)



canadianjameson
07-14-2003, 07:08 PM
after many failed attempts, i come to you a sad and broken man

i've been trying to get one of the two following scripts to work, but so far to no avail. my goal is to have a user select an option from one menu on a form, and based on that selection, have the options in a second menu change to reflect options of their choice.
i.e: first menu = company name
second menu = products sold by THAT company.

user selects company, the second menu changes to reflect the products of that company.

i have found two script on this site that allows me to do that, but i cant get them working with my data.

this script is preferable as it uses less actual code, but i have one small problem: http://www.js-examples.com/example/?ex=290&mode=2

The problem is that if one company has 9 products, and another has 6, if the user selects the company with 6, it'll display 3 blank slots.
if ANYONE knowws how to hide blank slots, that answers my question right there.
i would have posted the code, but the link above contains it.

the second script DOES hide blank slots, but the code is so complicated that i dont know how to actually edit it. and i only need 2 menus, and this one has 3: http://www.js-examples.com/example/?ex=458&mode=2

if anyone can explain in baby steps where to put my own info.... that works too.

lastly, if anyone has a simpler way to do this,... by all means

thanks,
-- Jay

p.s, also, eventually i'm going to have to have an event occur depending on what the user chooses in the second menu... so if anyone knows how to do that then please add it :D

Mr J
07-14-2003, 07:49 PM
Not too sure here but possibly something on these lines.




[SIZE=1]
<HTML><HEAD><TITLE>Populating Options</TITLE>
<SCRIPT language=JavaScript type=text/JavaScript>
<!--

// select 2 option values
var alpha_Array = new Array("Abacus","Abduct","Abided","Ablaze","Adapt");
var bravo_Array = new Array("Babies","Backup","Baffle","Bakery");
var charlie_Array = new Array("Cabled","Caches","Cactus");
var delta_Array = new Array("Dabble","Dainty");

function refill_select2(selected) {
form_name=document.forms["feedback"]
var selectedArray = eval(selected + "_Array");
while (selectedArray.length < form_name.select2.options.length) {
form_name.select2.options[(form_name.select2.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval("form_name.select2.options[i]=" + "new Option('" + selectedArray[i]+"')");
}
}

// End -->
</SCRIPT>
</HEAD>
<BODY onload="refill_select2('alpha')"><h1>Populating options</h1>
<center>
<FORM name="feedback">

<SELECT name="select1" onChange="refill_select2(this.form.select1.options[this.form.select1.selectedIndex].value)" size="1" style="width:100">
<option value="alpha">Options A</option>
<option value="bravo">Options B</option>
<option value="charlie">Options C</option>
<option value="delta">Options D</option>

</SELECT>

<SELECT name="select2" onChange="" size="1" style="width:100">
<!-- option value=""><-----------</option -->
</SELECT>
</center>
</BODY>
</HTML>

/SIZE]

canadianjameson
07-14-2003, 08:16 PM
good stuff, lemme try to modify it & see how i do :)

i may have newbie questions for you though :)

seems to be working.

how do i add an appostrophy? (')
putting \' doesnt work...

canadianjameson
07-15-2003, 09:38 PM
hello again. well, i got yesterdays dilema fixed thanks to Mr. J, now i need to take it a step further :)

so, i got my menu selection thing working, NOW what i need to do is have a seperate event occur for EACH different choice the user chooses in the second menu. for an understanding of what i'm trying to do, please see here

[thread reference redundent - previous thread is contained in this one]

my problem is as follows: in the code provided in the above post (which worked, thx Mr. J), the values for the second menu are stored in arrays in the <head> section
example:
var options_Array = new Array("Option A","Option B","Option C");

what i need to do is roughly have something like this occur:

when "Option A" selected, popup optionsA_specs.html
when "Option B" selected, popup optionsB_specs.html
when "Option C" selected, popup optionsC_specs.html

is this possible? i have seen it on other pages (i think)...
anyways, let me know

thanks,
-- Jay

brothercake
07-15-2003, 11:00 PM
Please keep responses to a thread in the same thread; I've merged them together.

canadianjameson
07-15-2003, 11:05 PM
ok brother, but do you think anyone will actually look at this now that its hidden as a response?

heres the plan, i leave it here for 2 days, if no one responds i'll repost it anew. fair enough?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum