Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help with this petty question...

Status
Not open for further replies.

adamrobo

Vendor
Jan 3, 2003
5
US
Hello...I have a really simple question that I need help with ASAP. Anyways, I have this script for an address book that has radio buttons A-Z, a submit button, and a separate window that displays results. It can be found at Anyways, What I want to do is use a drop down instead of radio buttons. What do I do? I have the drop down form all implemented in my script but I dont know what action or whatever to make it work. Help? Heres the code I have without the drop down, but with the radio buttons.

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var rcrd = new Object();
rcrd[0] = &quot;Gracie Allen, Javascript programmer, Tel. 234-5678 ext 13&quot;
+ &quot;\rHarold Ammons, DHTML scripts editor, Tel. 777-0987 ext 23&quot;
+ &quot;\rJames Atkin, Research and Development, Tel. 777-0933 ext 17&quot;;
rcrd[1] = &quot;George Burns, Database designer, Tel. 232-5178 ext 91&quot;
+ &quot;\rAnne Byzantine, Accountant, Tel. 456-0987 ext 33&quot;;
rcrd[2] = &quot;Harrison Czar, Administration, Tel. 232-5178 ext 12&quot;;
rcrd[3] = &quot;Dillard Dally, Corporate Efficiency, Tel. 232-5178 ext 88 &quot;
+ &quot;email: dillydally@corp.com&quot;
+ &quot;\rSandy Dodge, Secretarial, Tel. 456-6543 ext 44&quot;;
rcrd[4] = &quot;Heloise Eloise, Human Relations, Tel. 232-2909 ext 59&quot;
+ &quot;\rJerry Ezzard, Political Liasson, Tel. 456-9800 ext 41&quot;;
rcrd[5] = &quot;George Fatchance, Corporate Lending, Tel. 546-7712 ext 19&quot;
+ &quot;\rBjorn Fjord, Foreign Relations, Tel. 456-6651 ext 28&quot;;
function dataBase(isnform) {
for (var i = 0; i < 6; i++) {
if (isnform.alpha.checked) {
recnum = isnform.alpha.value;
}
}
if (rcrd[recnum] != null) {



document.isnform.display.value = rcrd[recnum];
}
else document.isnform.display.value = &quot;Sorry, no listings for that letter.&quot;;
}
// End Hiding Script -->
</SCRIPT>
</head>

<body>
<form name=&quot;isnform&quot;>
<input type=&quot;radio&quot; name=&quot;alpha&quot; value=&quot;0&quot;>A</font></p>
<input type=&quot;radio&quot; name=&quot;alpha&quot; value=&quot;1&quot;>B</font></p>
<input type=&quot;radio&quot; name=&quot;alpha&quot; value=&quot;2&quot;>C</font></p>
<input type=&quot;radio&quot; name=&quot;alpha&quot; value=&quot;3&quot;>D</font></p>
<input type=&quot;radio&quot; name=&quot;alpha&quot; value=&quot;4&quot;>E</font></p>
<input type=&quot;radio&quot; name=&quot;alpha&quot; value=&quot;5&quot;>F</font></p>
<input type=&quot;button&quot; name=&quot;but&quot; value=&quot; Find &quot; onclick=&quot;dataBase(this.form)&quot;></font></p>
<textarea name=&quot;display&quot; rows=&quot;4&quot; cols=&quot;57&quot;></textarea>
</FORM>
</body>
</html>

Thanks TONS
Adam
 
function dataBase() {
recNum = document.isnform.mySelect.selectedIndex note that the selectedIndex is equal to the value

if (rcrd[recnum] != null) {
document.isnform.display.value = rcrd[recnum];
}
else document.isnform.display.value = &quot;Sorry, no listings for that letter.&quot;;
}


<select name=mySelect>
<option value=0>A
<option value=1>B
<option value=2>C
<option value=3>D
<option value=4>E
</select>
<input type=&quot;button&quot; name=&quot;but&quot; value=&quot; Find &quot; onclick=&quot;dataBase(this.form)&quot;></font></p>
<textarea name=&quot;display&quot; rows=&quot;4&quot; cols=&quot;57&quot;></textarea> Get the Best Answers! faq333-2924
Happy 2003! [cheers]
mikewolf@tst-us.com
 
Heres what I came up with and it sill doesnt work :( What am I doing wrong?


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var rcrd = new Object();
rcrd[0] = &quot;Alt Lori K 419.627.4619 Email&quot;
+ &quot;\rAmaya Rick 419.627.4516 N/A&quot;
+ &quot;\rArmendariz Anna M 419.627.4614 Email&quot;
+ &quot;\rAust Linda P 419.627.4547 Email&quot;
+ &quot;\rBaum Ann E 419.627.4538 Email&quot;
+ &quot;\rBodi Kathy A 419.627.4554 Email&quot;
+ &quot;\rBransky Phyllis L 419.627.4670 Email&quot;
+ &quot;\rBuathier Cathy M 419.627.4651 Email&quot;
+ &quot;\rBundren Anna L 419.627.4537 Email&quot;
+ &quot;\rBurkey Judy A 419.627.4509 Email&quot;
+ &quot;\rButler James E 419.627.4538 Email&quot;
+ &quot;\rChrislip Meg C 419.627.4646 Email&quot;
+ &quot;\rClaar Deb 419.627.4517 Email&quot;
+ &quot;\rCullen Courtney B 419.627.4527 Email&quot;
+ &quot;\rDalferro Donna J 419.627.4551 Email&quot;
+ &quot;\rDonaldson Chris M 419.627.4527 Email&quot;
+ &quot;\rDorland Chris A 419.627.4565 Email&quot;
+ &quot;\rDoski Vicky L 419.627.4621 Email&quot;
+ &quot;\rDragstedt Joy L 419.627.4564 Email&quot;
+ &quot;\rDudek Kathy 419.627.4521 Email&quot;
+ &quot;\rFinneran Rich C 419.627.4659 Email&quot;
+ &quot;\rFrancis Dena 419.627.4517 N/A&quot;
+ &quot;\rGalloway Pam J 419.588.2095 Email&quot;
+ &quot;\rGasteier Marcia A 419.627.4502 Email&quot;;
rcrd[1] = &quot;George Burns, Database designer, Tel. 232-5178 ext 91&quot;
+ &quot;\rAnne Byzantine, Accountant, Tel. 456-0987 ext 33&quot;;
rcrd[2] = &quot;Harrison Czar, Administration, Tel. 232-5178 ext 12&quot;;
rcrd[3] = &quot;Dillard Dally, Corporate Efficiency, Tel. 232-5178 ext 88 &quot;
+ &quot;email: dillydally@corp.com&quot;
+ &quot;\rSandy Dodge, Secretarial, Tel. 456-6543 ext 44&quot;;
rcrd[4] = &quot;Heloise Eloise, Human Relations, Tel. 232-2909 ext 59&quot;
+ &quot;\rJerry Ezzard, Political Liasson, Tel. 456-9800 ext 41&quot;;
rcrd[5] = &quot;George Fatchance, Corporate Lending, Tel. 546-7712 ext 19&quot;
+ &quot;\rBjorn Fjord, Foreign Relations, Tel. 456-6651 ext 28&quot;;
function dataBase() {
recNum = document.isnform.mySelect.selectedIndex

if (rcrd[recnum] != null) {
document.isnform.display.value = rcrd[recnum];
}
else document.isnform.display.value = &quot;Sorry, no listings for that letter.&quot;;
}
</SCRIPT>
</head>
<form name &quot;isnform&quot;>
<select name=mySelect>
<option value=0>A
<option value=1>B
<option value=2>C
<option value=3>D
<option value=4>E
</select>
<input type=&quot;button&quot; name=&quot;but&quot; value=&quot; Find &quot; onclick=&quot;dataBase(this.form)&quot;></font></p>
<textarea name=&quot;display&quot; rows=&quot;4&quot; cols=&quot;57&quot;></textarea>
</form>
</body>
</html>
 
<input type=&quot;button&quot; name=&quot;but&quot; value=&quot; Find &quot; onclick=&quot;dataBase(this.form)&quot;></font></p>

Should read:
<input type=&quot;button&quot; name=&quot;but&quot; value=&quot; Find &quot; onclick=&quot;dataBase()&quot;></font></p> Get the Best Answers! faq333-2924
Happy 2003! [cheers]
mikewolf@tst-us.com
 
Hmmm...I still get an error...Did you test it at all?

Thank You
 
Two Problems:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var rcrd = new Object();
rcrd[0] = &quot;Alt Lori K 419.627.4619 Email&quot;
+ &quot;\rAmaya Rick 419.627.4516 N/A&quot;
+ &quot;\rArmendariz Anna M 419.627.4614 Email&quot;
+ &quot;\rAust Linda P 419.627.4547 Email&quot;
+ &quot;\rBaum Ann E 419.627.4538 Email&quot;
+ &quot;\rBodi Kathy A 419.627.4554 Email&quot;
+ &quot;\rBransky Phyllis L 419.627.4670 Email&quot;
+ &quot;\rBuathier Cathy M 419.627.4651 Email&quot;
+ &quot;\rBundren Anna L 419.627.4537 Email&quot;
+ &quot;\rBurkey Judy A 419.627.4509 Email&quot;
+ &quot;\rButler James E 419.627.4538 Email&quot;
+ &quot;\rChrislip Meg C 419.627.4646 Email&quot;
+ &quot;\rClaar Deb 419.627.4517 Email&quot;
+ &quot;\rCullen Courtney B 419.627.4527 Email&quot;
+ &quot;\rDalferro Donna J 419.627.4551 Email&quot;
+ &quot;\rDonaldson Chris M 419.627.4527 Email&quot;
+ &quot;\rDorland Chris A 419.627.4565 Email&quot;
+ &quot;\rDoski Vicky L 419.627.4621 Email&quot;
+ &quot;\rDragstedt Joy L 419.627.4564 Email&quot;
+ &quot;\rDudek Kathy 419.627.4521 Email&quot;
+ &quot;\rFinneran Rich C 419.627.4659 Email&quot;
+ &quot;\rFrancis Dena 419.627.4517 N/A&quot;
+ &quot;\rGalloway Pam J 419.588.2095 Email&quot;
+ &quot;\rGasteier Marcia A 419.627.4502 Email&quot;;
rcrd[1] = &quot;George Burns, Database designer, Tel. 232-5178 ext 91&quot;
+ &quot;\rAnne Byzantine, Accountant, Tel. 456-0987 ext 33&quot;;
rcrd[2] = &quot;Harrison Czar, Administration, Tel. 232-5178 ext 12&quot;;
rcrd[3] = &quot;Dillard Dally, Corporate Efficiency, Tel. 232-5178 ext 88 &quot;
+ &quot;email: dillydally@corp.com&quot;
+ &quot;\rSandy Dodge, Secretarial, Tel. 456-6543 ext 44&quot;;
rcrd[4] = &quot;Heloise Eloise, Human Relations, Tel. 232-2909 ext 59&quot;
+ &quot;\rJerry Ezzard, Political Liasson, Tel. 456-9800 ext 41&quot;;
rcrd[5] = &quot;George Fatchance, Corporate Lending, Tel. 546-7712 ext 19&quot;
+ &quot;\rBjorn Fjord, Foreign Relations, Tel. 456-6651 ext 28&quot;;
//RecNum != recnum != recNum (oops! - sorry - I need to watch my case)
function dataBase() {
recnum = document.isnform.mySelect.selectedIndex
if (rcrd[recnum] != null) {
document.isnform.display.value = rcrd[recnum];
}
else document.isnform.display.value = &quot;Sorry, no listings for that letter.&quot;;
}
</SCRIPT>
</head>
<form name=&quot;isnform&quot;> You were missing the equals(=) sign
<select name=&quot;mySelect&quot;>
<option value=0>A
<option value=1>B
<option value=2>C
<option value=3>D
<option value=4>E
</select>
<input type=&quot;button&quot; name=&quot;but&quot; value=&quot; Find &quot; onclick=&quot;dataBase()&quot;></font></p>
<textarea name=&quot;display&quot; rows=&quot;4&quot; cols=&quot;57&quot;> Get the Best Answers! faq333-2924
Happy 2003! [cheers]
mikewolf@tst-us.com
 
Thank You tons, it was that damn capital R that was killing me, hahaha. Thanks again!
 
mwolf00...1 more question...can I add links within the javascript that has the record information in the head? Im trying but its not working.
 
I'm not sure exactly what you are trying to do.... Get the Best Answers! faq333-2924
Happy 2003! [cheers]
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top