/    Sign up×
Community /Pin to ProfileBookmark

Hey everyone, your site has been a great help to me. I got a quick (well hopefully) question. I’m trying to have an array set up, something similiar to this [URL=http://us.creative.com/support/downloads/]http://us.creative.com/support/downloads/[/URL]

Mine wont be as complicated or as many choices. Basically the first set of options the users will select a Year. Depending on the year, the next choice they’d recieve would be to select a specific month’s from that year and see the report from that month after hitting the select/go button. I’ve tried a few things but now have all but almost given up. Please help!!!11

thanks everyone.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@FangJun 28.2005 — Something like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Change selection in one box from another</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
<!--
var varieties=[
["varieties","granny smith","golden delicious","jonathan"],
["varieties","anjou","bartlett","conference"],
["varieties","valencia","pineapple","pera"]
];

function Box2(idx) {
var f=document.myform;
f.box2.options.length=null;
for(i=0; i<varieties[idx].length; i++) {
f.box2.options[i]=new Option(varieties[idx][i], i);
} <br/>
}

function selected() {
var f=document.myform;
alert(f.box1.options[f.box1.selectedIndex].text+":"+f.box2.options[f.box2.selectedIndex].text);
}

onload=function() {
Box2(0);
}
//--&gt;
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form name="myform" action="#" onsubmit="selected();"&gt;
&lt;div&gt;
&lt;select name="box1" onchange="Box2(this.selectedIndex);"&gt;
&lt;option value="a"&gt;apple&lt;/option&gt;
&lt;option value="b"&gt;pear&lt;/option&gt;
&lt;option value="c"&gt;orange&lt;/option&gt;
&lt;/select&gt;
&lt;select name="box2"&gt; <br/>
&lt;/select&gt;
&lt;button type="submit"&gt;submit&lt;/button&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@prlitauthorJun 28.2005 — Yeah something like that, except instead of drop down boxes we would have like a text box. And once the values were chosen and clicked submit, it would redirect you to the correct page. I'm not to knowledgeable with Javascript so I wouldn't really have the slightest clue where to begin.
Copy linkTweet thisAlerts:
@prlitauthorJun 28.2005 — [URL=http://www.prldocs.com/test/javatest.htm]Here's our test page.[/URL]

Thats how we have it setup, but are basically lacking the script/code to actually have it submit based on the value. Also how would we setup that report3 would link to the url http://www.blah.com/report3.htm

thanks everyone.
Copy linkTweet thisAlerts:
@prlitauthorJun 29.2005 — /bump still lookin for help.
Copy linkTweet thisAlerts:
@FangJun 29.2005 — The example page you gave in the#1 post uses <select> with size set to the longest <select>.

Using <textarea> (text box) would be unnecessarily complicated.
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Change selection in one box from another&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;script type="text/javascript"&gt;
&lt;!--
var varieties=[
["varieties","granny smith","golden delicious","jonathan"],
["varieties","anjou","bartlett","conference"],
["varieties","valencia","pineapple","pera"]
];

function Box2(idx) {
var f=document.myform;
f.box2.options.length=null;
for(i=0; i&lt;varieties[idx].length; i++) {
f.box2.options[i]=new Option(varieties[idx][i], i);
} <br/>
}

function selected() {
var f=document.myform;
//alert(f.box1.options[f.box1.selectedIndex].text+":"+f.box2.options[f.box2.selectedIndex].text);
document.location.href='http://www.blah.com/'+f.box1.options[f.box1.selectedIndex].text+'/'+f.box2.options[f.box2.selectedIndex].text+'.html';
return false;
}

onload=function() {
Box2(0);
}
//--&gt;
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form name="myform" action="#" onsubmit="return selected();"&gt;
&lt;div&gt;
&lt;select name="box1" onchange="Box2(this.selectedIndex);" size="4"&gt;
&lt;option value="a"&gt;apple&lt;/option&gt;
&lt;option value="b"&gt;pear&lt;/option&gt;
&lt;option value="c"&gt;orange&lt;/option&gt;
&lt;/select&gt;
&lt;select name="box2" size="4"&gt; <br/>
&lt;/select&gt;
&lt;button type="submit"&gt;submit&lt;/button&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@prlitauthorJun 29.2005 — Excellent. Thanks Fang.
×

Success!

Help @prlit 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.8,
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,
)...