PDA

View Full Version : 2 drop down menus - help needed


tommysphone
11-29-2002, 04:01 PM
I have a problem. I am building a form that includes two drop downs (placed near the end of the form). The first menu has 4 options and I require the second drop down to have different selection options displayed depending on the selection in the first menu.

example

drop down 1 has the following options

1
2
3
4
5

drop down 2 would look as follows is 1 is selected
a
b
c
d
e

drop down 2 would look as follows is 2 is selected
am
pm
cd
bn
dw
dw
fr

Can anyone help this perplexed brain of mine? In hope.

dmdb1423
11-29-2002, 11:54 PM
There's a website I've found while learning javascript which actually includes an automatic generator for select lists like this but will need a bit of modification to intregate it into part of an existing form.

http://www.webteacher.com/javascript/changing_lists.html

might help?

tommysphone
12-03-2002, 11:02 AM
That was a big help. Thank you.

tommysphone
12-09-2002, 09:03 AM
Hi all.

Right,I have a form which has amongst other things, two drop down menus.The selection in one (PRODUCT) produces options in another (URL_Required).This is where I am stuck.I want the user to see normal words in the field called link required (URL_Required).EG:for http://www.yahoo.com I would like the user to see Yahoo as the option.I'd like to display plain english but have the url selected appear in the email so it can be clicked on.

<%@ Language=VBScript %>
<%
If Request.Form("txtNew") = "True" Then
'******************************* START EMAIL STUFF *************************************
strURL = "<a href=" & request.form("URL_Required") & ">" & request.form("URL_Required") & "</a>"
Set objMail = CreateObject("CDONTS.Newmail")
objMail.From = request.form("OFFICE")
objMail.To = request.form("txtCustomerEmail")
objMail.Subject = "Email title here"
objMail.bodyformat = 0
objMail.mailformat = 0
strTmpStr = "<table border=""0"" width=""100%"" cellpadding=""0""><tr><td width=""100%"" height=""30"" valign=""top"" align=""left""><font face=""Tahoma"">Dear "& request.form("txtCustTitle") &" "& request.form("txtCustomersSurname") &",</font></td></tr><tr><td width=""100%"" valign=""top"" align=""left""><font face=""Tahoma""> Thank you for contacting us. Please find below a link which may assist you in the future.</font></td></tr><tr><td width=""100%"" height=""30"" valign=""top"" align=""left""><font face=""Tahoma"">"& strURL &"</font></td></tr><tr><td width=""100%"" valign=""top"" align=""left"" height=""60""><font face=""Tahoma"">Please do not hesitate to contact us again if we may be of further assistance.</font></td></tr><tr><td width=""100%"" height=""20"" valign=""top"" align=""left""><font face=""Tahoma"">Regards,</font></td></tr><tr><td width=""100%"" valign=""top"" align=""left""><font face=""Tahoma"">"& request.form("Employee_Name") &"</font></td></tr><tr><td width=""100%"" valign=""top"" align=""left""><font face=""Tahoma"">Polite ending here</font></td></tr></table>"
objMail.Body = "<html><head></head><body>" & strTmpStr & "</body></html>"
objMail.Send
Set objMail = Nothing
'******************************* END EMAIL STUFF *************************************
End If
%>
<html>

<head>
<title>URL mailer</title>
<a validation script here>
<script>

platform=window.navigator.appVersion;
ie3=0;
if (platform.indexOf('MSIE 3')>0) {
ie3=1;
}

One=new Array()
One[0]="http://www.yahoo.com";
One[1]="http://www.lycos.com";

Two=new Array()
Two[0]="http://www.shell.com";
Two[1]="http://www.yell.com";
Two[2]="http://www.codingforums.com";

Three=new Array()
Three[0]="http://www.ibm.com";
Three[1]="http://www.192.com";
Three[2]="http://www.brinkster.com";
Three[3]="http://www.asp.net";

Four=new Array()
Four[0]="http://www.devx.com";
Four[1]="http://www.amazon.com";

Five=new Array()
Five[0]="http://www.freefind.com";
Five[1]="http://www.javascript.com";
Five[2]="http://www.guistuff.com";
Five[3]="http://www.voicexmlplanet.com";
Five[4]="http://www.virgin.com";

function setList(f) {
if (ie3) {
alert('Changable lists do not work with Internet Explorer 3');
return;
};
secondlist=eval(f.PRODUCT.options[f.PRODUCT.selectedIndex].value);
f.URL_Required.options.length=0;
for(i=0;i<secondlist.length;i++) {
f.URL_Required.options[i]=new Option(secondlist[i]);
};
f.URL_Required.selectedIndex=0;
};
</script>
</head>
<%If Request.Form("txtNew") <> "True" Then%>

<body>
<%Set User = Server.CreateObject("Intranet.User")%>

<form method="POST" name="urlmailer" action="_urlmailer_list_changes_urltochooseV2.asp">
<input type="hidden" name="txtNew" value="True"><table border="0" width="534"
cellspacing="1" cellpadding="0">
<tr>
<td width="20" valign="top" align="left"></td>
<td width="460" valign="top" align="left" colspan="3"><strong><h1>Form title</h1>
</strong></td>
</tr>
<tr>
<td width="20" valign="top" align="left"></td>
<td class="form-section" width="460" valign="top" align="left" colspan="3"><big><strong>Employee
details</strong></big></td>
</tr>
<tr>
<td width="20" valign="top" align="left"></td>
<td class="form-col1" width="289" valign="top" align="left"><strong>Your Name:</strong></td>
<td class="form-col2" valign="top" align="left" width="205" colspan="2"><input type="text"
name="Employee_Name" size="39" style="font-size: 10pt">*</td>
</tr>
<tr>
<td width="20" valign="top" align="left"></td>
<td class="form-col1" width="289" valign="top" align="left"><strong>Your office</strong></td>
<td class="form-col2" valign="top" align="left" width="5" colspan="2"><select
name="OFFICE" size="1" style="font-size: 10pt">
<option value="Select">Select</option>
<option value="a1.person@domain.com">Office 1</option>
<option value="a2.person@domain.com">Office 2</option>
<option value="a.person@domain.co.uk">Office 3</option>
</select>*</td>
</tr>
<tr>
<td width="20" valign="top" align="left"></td>
<td class="form-section" width="460" valign="top" align="left" colspan="3"><big><strong>Recipient
details</strong></big></td>
</tr>
<tr>
<td width="20" valign="top" align="left"></td>
<td class="form-col1" width="289" valign="top" align="left"><strong>Customers title:</strong></td>
<td class="form-col2" valign="top" align="left" width="5" colspan="2"><select
name="txtCustTitle" size="1" style="font-size: 10pt">
<option value="Select">Select</option>
<option value="Mr">Mr</option>
<option value="Master">Master</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
<option value="Dr">Dr</option>
<option value="Rev">Rev</option>
</select>*</td>
</tr>
<tr>
<td width="20" valign="top" align="left"></td>
<td class="form-col1" width="289" valign="top" align="left"><strong>Customers surname:</strong></td>
<td class="form-col2" valign="top" align="left" width="5" colspan="2"><input type="text"
name="txtCustomersSurname" size="39" style="font-size: 10pt">*</td>
</tr>
<tr>
<td width="20" valign="top" align="left"></td>
<td class="form-col1" width="289" valign="top" align="left"><strong>Product:</strong></td>
<td class="form-col2" valign="top" align="left" width="205" colspan="2"><select
NAME="PRODUCT" onChange="setList(form)" size="1" style="font-size: 10pt">
<option VALUE="Select" SELECTED>Select</option>
<option VALUE="One">Some links</option>
<option VALUE="Two">Some other links</option>
<option VALUE="Three">Links</option>
<option VALUE="Four">More links</option>
<option VALUE="Five">Last lot of links</option>
</select>*</td>
</tr>
<tr>
<td width="20" valign="top" align="left"></td>
<td class="form-col1" width="289" valign="top" align="left"><strong>Customer Email
Address:</strong></td>
<td class="form-col2" valign="top" align="left" width="205" colspan="2"><input type="text"
name="txtCustomerEmail" size="39" style="font-size: 10pt">*</td>
</tr>
<tr>
<td width="20" valign="top" align="left" bgcolor="#FFFFFF"></td>
<td class="form-col1" width="289" valign="top" align="left"><strong>Link required</strong></td>
<td class="form-col2" valign="top" align="left" width="205" colspan="2"><select
NAME="URL_Required" size="1" style="font-size: 10pt">
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select></td>
</tr>
<tr>
<td width="20" valign="top" align="left" bgcolor="#FFFFFF"></td>
<td class="form-col1" width="494" valign="top" align="left" height="20" colspan="3"></td>
</tr>
<tr>
<td width="20" valign="top" align="left" bgcolor="#FFFFFF"></td>
<td class="form-col1" width="289" valign="top" align="left" height="20"></td>
<td class="form-col2" valign="top" align="left" width="90" height="20"><div align="center"><center><p><input
type="button" value="Send to customer" onClick="SubmitForm()" style="font-size: 10pt"></td>
<td class="form-col2" valign="top" align="center" width="115" height="20"><div
align="left"><p><input type="reset" value="Clear" name="B2" style="font-size: 10pt"></td>
</tr>
<tr align="center">
<td width="20" valign="top" align="left" bgcolor="#FFFFFF"></td>
<td width="460" valign="top" align="left" colspan="3"><table border="0" width="100%"
cellspacing="0" cellpadding="0">
<tr>
<td width="100"></td>
<td><div align="center"><center><p>&nbsp;&nbsp;&nbsp; </td>
<td width="100" align="center"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<%Set User = Nothing%>
<% Else %>
<small>

<p align="center"></small>Thank you for submiting this form, an email has now been sent to
the customer with the following details:<big> </big><strong></p>
<% response.write strTmpStr %>
<small><strong>

<p align="center"></strong></small></strong>If you feel there is any sort of problem with
this form, please inform a name here immediately. Thank you.</p>

<p align="center">Please click&nbsp; <a href="_urlmailer_list_changes_urltochooseV2.asp#"
onClick="history.go(-1)">here</a> to return to the last page and send another url</p>

<p align="center"><strong>&nbsp;<%End if%> </strong></p>
</body>
</html>
In hope

tommysphone
12-09-2002, 10:47 AM
Changed

function setList(f) {
if (ie3) {
alert('Changable lists do not work with Internet Explorer 3');
return;
};
secondlist=eval(f.PRODUCT.options[f.PRODUCT.selectedIndex].value);
f.URL_Required.options.length=0;
for(i=0;i<secondlist.length;i++) {
f.URL_Required.options[i]=new Option(secondlist[i]);
};
f.URL_Required.selectedIndex=0;
}
}

to read

function SetList(curProduct) // pass in the current Product index
{
if ( curProduct < 0 ) return; // no product selected, so do nothing

var aryURL = document.urlmailer.URL_Required.options; // points to URL_Required options array

aryURL.length=0; // first, clear the current Product options ...

// then re-load the URL options with values for the current Product
for ( var i=0,n=aryProduct[curProduct].length; i<n; i++ )
{

aryURL.length++; // add a new Option, then put data in it (below)
aryURL[aryURL.length-1].text = aryProduct[curProduct][i].text;
aryURL[aryURL.length-1].value = aryProduct[curProduct][i].value;
}
}
Works a treat. Thanks to anyone who was going to post a reply or does. I'll read with interest.