View Full Version : [RESOLVED] How to Create a Quick Lookup
shanebo2003
07-11-2007, 10:29 AM
I am in need of a little help, fellas.
I need to create a quick lookup where an output value can be generated. For instance, if there are three drop-down menus of values to choose from and three are chosen, then I need an output text box to show something like "value1.value2.value3" or something to that effect. Here is a clearer picture of what I am looking for:
Menu 1 : Choose Color
Menu 2 : Choose Number
Menu 3 : Choose Letter
Output Field : ColorChosen.NumberChosen.LetterChosen
Can anyone help point me in the right direction? Or at least provide another web page with something similar for me to mimic? Thanks!
Pegasus
07-11-2007, 12:12 PM
http://www.a1javascripts.com/form_navigation/doublecombo/doublecombo.html
Something like this?
Peg
coothead
07-11-2007, 01:08 PM
Hi there shanebo2003,
and a warm welcome to these forums. :agree:
This question should really be in the javascript forum ;) but while it is here I will post a possible solution...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dropdown values as input value</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#container {
width:400px;
padding:20px;
border:3px double #999;
text-align:center;
margin:auto;
}
input{
width:400px;
text-align:center;
margin-top:20px;
}
</style>
<script type="text/javascript">
var df;
window.onload=function() {
df=document.forms[0]
sel=df.getElementsByTagName('select');
for(c=0;c<sel.length;c++) {
sel[c].id=c;
sel[c].onchange=function() {
displayValues(this.value,this.id)
}
}
}
function displayValues(va,id){
switch(id){
case '0':
df[3].value='color is : '+va+
', number is : '+df[1].value+
', letter is : '+df[2].value;
break;
case '1':
df[3].value='color is : '+df[0].value+
', number is : '+va+
', letter is : '+df[2].value;
break;
case '2':
df[3].value='color is : '+df[0].value+
', number is : '+df[1].value+
', letter is : '+va;
break;
}
}
</script>
</head>
<body>
<form action="#">
<div id="container">
<div>
<select>
<option value="unselected">color</option>
<option value="red">red</option>
<option value="orange">orange</option>
<option value="yellow">yellow</option>
<option value="green">green</option>
<option value="blue">blue</option>
<option value="violet">violet</option>
<option value="brown">brown</option>
<option value="black">black</option>
<option value="white">white</option>
<option value="grey">grey</option>
</select>
<select>
<option value="unselected">number</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<select>
<option value="unselected">letter</option>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
<option value="f">f</option>
<option value="g">g</option>
<option value="h">h</option>
<option value="i">i</option>
<option value="j">j</option>
<option value="k">k</option>
<option value="l">l</option>
<option value="m">m</option>
<option value="n">n</option>
<option value="o">o</option>
<option value="p">p</option>
<option value="q">q</option>
<option value="r">r</option>
<option value="s">s</option>
<option value="t">t</option>
<option value="u">u</option>
<option value="v">v</option>
<option value="w">w</option>
<option value="x">x</option>
<option value="y">y</option>
<option value="z">z</option>
</select>
</div>
<div>
<input type="text"/>
</div>
</div>
</form>
</body>
</html>
shanebo2003
07-11-2007, 02:00 PM
Thanks for yall's help. I believe that coothead is on the right track, but I need a little further assistance.
Here is the problem with the solution you prepared for me. These 3 data fields that I gave you won't be color, number, and letter....they will be something completely different and more complicated. Therefore, to simplify what I am looking for, I need the text bar at the bottom to read "Your Code Is: Red.One.A" when those are selected. It would also help if there was an action button to retrieve the code, but I understand if you can't provide that for me.
Is there the possibility that you (coothead) could make this change and show me a possible script? I will be forever grateful as a newbie to the forums!
Thanks!!!
coothead
07-11-2007, 02:56 PM
Hi there shanebo2003,
does this help...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dropdown values as input value</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#container {
width:250px;
padding:20px;
border:3px double #999;
text-align:center;
margin:auto;
}
input{
width:216px;
text-align:center;
margin-top:20px;
}
</style>
<script type="text/javascript">
var df;
window.onload=function() {
df=document.forms[0]
sel=df.getElementsByTagName('select');
for(c=0;c<sel.length;c++) {
sel[c].id=c;
sel[c].onchange=function() {
setValues(this.value,this.id)
}
}
df[4].onclick=function() {
displayValues();
}
}
function setValues(va,id){
switch(id){
case '0':
code='Your code is: '+va+
'.'+df[1].value+
'.'+df[2].value;
break;
case '1':
code='Your code is: '+df[0].value+
'.'+va+
'.'+df[2].value;
break;
case '2':
code='Your code is: '+df[0].value+
'.'+df[1].value+
'.'+va;
break;
}
}
function displayValues() {
if((df[0].value!='unselected')&&
(df[1].value!='unselected')&&
(df[2].value!='unselected')){
df[3].value=code;
}
}
</script>
</head>
<body>
<form action="#">
<div id="container">
<div>
<select>
<option value="unselected">color</option>
<option value="red">red</option>
<option value="orange">orange</option>
<option value="yellow">yellow</option>
<option value="green">green</option>
<option value="blue">blue</option>
<option value="violet">violet</option>
<option value="brown">brown</option>
<option value="black">black</option>
<option value="white">white</option>
<option value="grey">grey</option>
</select>
<select>
<option value="unselected">number</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<select>
<option value="unselected">letter</option>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
<option value="f">f</option>
<option value="g">g</option>
<option value="h">h</option>
<option value="i">i</option>
<option value="j">j</option>
<option value="k">k</option>
<option value="l">l</option>
<option value="m">m</option>
<option value="n">n</option>
<option value="o">o</option>
<option value="p">p</option>
<option value="q">q</option>
<option value="r">r</option>
<option value="s">s</option>
<option value="t">t</option>
<option value="u">u</option>
<option value="v">v</option>
<option value="w">w</option>
<option value="x">x</option>
<option value="y">y</option>
<option value="z">z</option>
</select>
</div>
<div>
<input type="text"/>
</div>
<div>
<input type="button" value="show code"/>
</div>
<div>
<input type="reset" value="rest fields"/>
</div>
</div>
</form>
</body>
</html>
shanebo2003
07-11-2007, 03:00 PM
YES! Thank you for your help! I will let you know if I need any more help!
THANKS AGAIN!
coothead
07-11-2007, 03:02 PM
No problem, you're very welcome. :agree:
shanebo2003
07-12-2007, 01:38 PM
One more thing that is giving me trouble....
There are only certain instances where I need these numbers and letters. For instance, if someone chooses red as the color, then i need for only 1 and 2 to show up under numbers because Red doesnt have 3,4,5,6, and so on. The same goes for letters, too.
I need to find a way to make sure that when Red is chosen, only a certain few of the next number and letter choices are given instead of the whole lot of them. Can anyone help me with this?
Thanks!
coothead
07-12-2007, 06:26 PM
Hi there shanebo2003,
check out the attachment for further developments. ;)
shanebo2003
07-13-2007, 03:37 PM
What if I needed different values to show up when the button is pressed? For instance, have the box say "1" but have the lookup read "red.ONE.a"?
coothead
07-13-2007, 03:54 PM
Hi there shanebo2003,
well, you can check the new attachment. ;)
shanebo2003
07-16-2007, 11:00 AM
And one last question....
Going along with an earlier question, how would i create a second hierarchical level on the second drop box? For example, you already helped me out on the first one where red only has two numbers attached to it. But it seems that as it is now, the letters drop menu is attached to the first 'color' level and not the second 'number' level. How would i go about creating a second level saying that, for instance, if there is TWO is chosen in any instance, then B is the only letter option?
Thanks for all your help so far!
coothead
07-16-2007, 12:18 PM
Hi there shanebo2003,
to make this a little easier for me and to save time also could you supply a complete list of available options.
What I need then is the combinations of numbers available to each color and the combinations of letters available to each number.
shanebo2003
07-16-2007, 12:42 PM
Let's just keep it simple and keep it to two colors...
Red > 1 > A
Red > 1 > B
Red > 1 > C
Red > 1 > D
Red > 1 > E
Orange > 2 > F
Orange > 2 > G
Orange > 3 > F
Orange > 3 > G
Does that make sense to you? When I select Red, I want only the number ONE to pop up because there is only one choice available. Then once one is chosen, there are 5 letters available.
On Orange, I would like TWO and THREE to pop up as available, and then for both of them, F and G are the only available letters.
Let me know if you need more clarification. Thanks!
coothead
07-17-2007, 09:13 AM
Hi there shanebo2003,
Let's just keep it simple and keep it to two colors...
Well, I'm pleased that you think that two colors keeps this simple. :rolleyes:
In fact, with that sort of thinking I'm surprised that you did not do this project yourself. ;)
As you will see from the size of the javascript file there are many lines of coding required for two colors. :agree:
Anyway, you now have the basic structure that will allow you to add options in the first select element. :)
shanebo2003
07-17-2007, 10:15 AM
Thanks for all of your help coothead!
On another note, maybe you could be nicer in your approach to the new guys around here....
coothead
07-17-2007, 12:39 PM
Hi there shanebo2003,
...maybe you could be nicer in your approach to the new guys around here.
I am sorry that you believe that to be the case. :(
But if you genuinely do, perhaps you should draw an administrator's attention to this post and ask for a second opinion. ;)
Pegasus
07-17-2007, 01:00 PM
An admin has been watching this forum and there's nothing wrong with the way Coothead has been treating you, Shanebo. Coothead has done/redone the code you need five times without complaint.
What you ask isn't easily done, although it may sound easy. It would also help if you adjusted *your* attitude towards people who are trying to help you. "Help" does not mean "do for" and a bit of effort and thought on your part would be appreciated.
Pegasus
shanebo2003
07-17-2007, 01:35 PM
Did I ever say that there was something wrong with the way he was treating me? No sir, I did not. That statement would have looked a little something like this....
"Coothead, there is something wrong with the way you are treating me."
I said that, perhaps, making pithy comments about a new member to the forums doesn't exactly welcome them to the site.
Maybe you haven't been following this forum as closely as you should have! I never asked coothead to write an entire script for me - I merely asked him what something would look like or if I could possibly get some help regarding a certain subject.
So, in summary, I thank coothead for all he has done - he has gone above and beyond expectations. I also would like to suggest Pegasus do actual admin work...
Pegasus
07-17-2007, 01:56 PM
And which pithy comment are you referring to? I don't see any except what came from you.
shanebo2003
07-17-2007, 02:14 PM
You still must not be monitoring this forum close enough then...
Pegasus
07-17-2007, 02:35 PM
Let me rephrase that, then. I know Coothead. What he's written is in character for him and I see no problem with it, nor have I had any complaints about his attitude. Until now.
What remark(s), specifically, are you referring to?
shanebo2003
07-18-2007, 11:46 AM
It's pretty obvious if you would just scan the forum like admins usually do...
Maybe you should take into account that since you "know" Coothead, his humor and character do not translate over the internet....
Likewise, maybe you should take into account that my character is of the same nature...
Pegasus
07-18-2007, 12:55 PM
If I have to ask, then it's not obvious to me. If you're going to level a complaint at a member, please be prepared to back up your statements with specifics. *I* have no idea what you're talking about and you're not willing to point it out so I can understand. Does this mean that there's nothing wrong with what Coot said and you're just trying to cause trouble for him? I don't know. Help me out here.
shanebo2003
07-18-2007, 03:38 PM
Since you aren't able to look at the forum and see what I responded to, here it is:
Hi there shanebo2003,
Well, I'm pleased that you think that two colors keeps this simple. :rolleyes:
In fact, with that sort of thinking I'm surprised that you did not do this project yourself. ;)
As you will see from the size of the javascript file there are many lines of coding required for two colors. :agree:
This is obviously condescending and a sarcastic manner of approach. He even uses a "rolling eyes" smiley to point this out. As you know, sarcasm doesnt translate well over the internet... :rolleyes:
I do not even know why you are making this a huge deal - I said that he could be a bit nicer to newbies, and that's it. Coothead didn't take offense to that, and it was an obvious misunderstanding. Your inability to monitor these forums coherently is increasingly alarming....just let it die.....
Pegasus
07-18-2007, 04:01 PM
Coothead took this up in private with me. He was offended by your words, as was I. Several hours of coding went into those projects, if you'd taken a good look at them. You brushed that off like it was nothing. What does that say for your attitude?
Also, I asked you several times to tell me what you thought was offensive and you refused to answer, telling me that I should know. I *don't* know what you're thinking. That's why I asked. My job, when there is a conflict, is to ascertain *both* sides of the story. It would have been a much simpler matter if you'd just cited the offending post in the first place and have done with it.
shanebo2003
07-18-2007, 05:08 PM
I am terrrrrrrribly sorry for my transgressions. I didn't know you needed me to take you by the hand and point to you the post that i directly replied to....
I thanked Coothead many times for his help. That is all I can do besides me offering to pick up his tab at the next bar I see him at. When I get pointed comments thrown at me, I let the person know. Sorry, but that's what his comments were....pointed.
You should leave this matter alone, like I suggested earlier. Don't even bother to reply....there is no point. He said something sarcastic and condescending....i reacted....he said he didnt mean it.....and that is that.....I don't know why you are still in this conversation....besides the fact that you still cannot find the post I replied to.
In case you haven't been an admin for long....this is how forums go...
1) Person A authors a post
2) Person B responds
In case you missed that, Person B responds to the post of Person A. Therefore, if you are wondering what Person B (in this case, myself) is referring to, check the post of Person A directly before.
Class dismissed.
shanebo2003
07-25-2007, 10:43 AM
Thanks, once again Coothead, for all the help you have given me.
I have unfortunate news, though. The script you last offered was exactly what I needed, but it does not allow me to change the values inside the arrays like I asked about earlier, so it is not as helpful as I would have hoped.
Thanks for trying though!!!
shanebo2003
07-30-2007, 02:32 PM
Thanks for interfering, Pegasus. Now Coothead is mad at me because you made a big deal out of nothing...
Pegasus
07-30-2007, 04:59 PM
Of course, your sarcastic attitudes towards both a mod and Coothead wouldn't have anything to do with that, would it?
shanebo2003
08-01-2007, 11:32 AM
Nope, not at all....your tendency to butt-in when you are not needed or wanted did that...
BillyGalbreath
08-01-2007, 12:07 PM
Wicked read! lol
shanebo2003
08-08-2007, 12:25 PM
Is anyone willing to help with my problem? This thread was turned into reading material instead of actually solving my problem. I am not able to attach different array values for the last script that coothead offered, and I am at a standstill as of now.
Anyone?
BillyGalbreath
08-08-2007, 12:40 PM
shanebo2003... coothead has helped you countless times, all small simple tasks that you should have learned from. The reason no one is helping anymore (including coothead) is because it appears that you are here for a quick answer, not to learn. You are taking what coothead gives you and then you tell him its not exactly what you wanted, so he revises it serveral times and you keep telling him things to change/edit. He helped you out big time, more than once. It's time you look over the code and learn what he did, that way you can take over with the project. It's now that time for you to take over...
"Give a man a fish and he'll eat for a day. Teach a man to fish and he'll have food for the rest of his life."
shanebo2003
08-08-2007, 02:15 PM
Wow.....
"Give a man a fish, feed him for a day. Teach a man to fish, feed him for a lifetime."
Just wanted to let you know that it was a good point, but only if it is actually a quote...
BillyGalbreath
08-08-2007, 02:35 PM
http://www.quotationspage.com/quote/2279.html <- pretty much what I said, just in my own words.
shanebo2003
08-08-2007, 02:35 PM
Also, it's pretty hard to learn what coothead graciously did for me when he did something completely different every time, and changed up the whole script in the last installment. I am assuming this is a simple fix, and if it looked anything like it did when this was the problem earlier, i probably would be able to figure it out.
BillyGalbreath
08-08-2007, 02:47 PM
Well - have you gone over his code? You need to figure out what his code is doing exactly (even if its not what you wanted it to do) and then figure out the code so you'll know how he made it do what its doing. After that its just a matter of aplying what you want it to do by editing his code.
the reason he changed the entire structure so many times is because your want changed dramatically every single time. To be honest, the task you are wanting to do is not all that simple, and the end result wanted is going to cause the code to vary greatly from what was given.
I'm not going to rewrite the whole thing my way - I don't see you benifiting from that. However, if you attempt to recode it yourself (after learning what coothead provided) then I will be more than happy to help you with much more specific help. Something with this broad of a scope is going to be difficult, so instead take it little piece by piece.
shanebo2003
08-08-2007, 02:50 PM
I will be happy to work with you on this....the problem is that I don't know where to start. If you can tell me of a place to start, that would be helpful.
BillyGalbreath
08-08-2007, 02:55 PM
The starting point is where coothead left off with his last script.
You need to figure out what his script is doing, and learn the code he wrote to do those actions. After that you need to figure out everything his script lacks that you need it to do.
From there it gets easier. Please get as detailed as you can be when figuring out what coothead's script lacks. In fact - stop using colors, numbers and letters. Start using what the end result is going to use. Whatever it is I'm sure it's not top secret government information that you are trying to keep out of public hands, or else you wouldn't be here in the first place. ;)
shanebo2003
08-08-2007, 03:03 PM
For starters, here is what I am actually working with....
Now, the only problem I have now is that I am unable to find a way to display these array values differently than what shows in the drop-down menu. Much like the ".value" and ".innerhtml" with the options method coothead previously showed me, but that doesn't seem to work here. I am sure there is some sort of function that does this, but I have yet to stumble upon it in my research.
BillyGalbreath
08-08-2007, 03:15 PM
Where is the rest of the page in the file?
shanebo2003
08-08-2007, 03:58 PM
Here is the rest of it...sorry for not including it in the first place...
Is there a SetValues function that needs to be added?
BillyGalbreath
08-08-2007, 05:06 PM
Ok - I've cleaned up your file so that its more easily readable. It works perfectly as well. I don't think I am understanding your question here.
What is it exactly that you want to change? Be as detailed as you can in answering that question for me.
shanebo2003
08-09-2007, 10:19 AM
I know the tool works perfectly....coothead was very helpful!
Here is the problem...whenever the second and third menu choices are chosen and the submit button is hit, I need to pop out a different value than what is actually shown in the menus. For instance, instead of "TSG IT", I need to pop up a code that looks like gibberish. This is why I said it was like the .value an .innerhtml coothead used earlier because I need one thing to show but another to pop out in the output box.
Understand?
BillyGalbreath
08-09-2007, 12:17 PM
Ok I get it. Let me study the code a bit longer then I'll help you out. And no, this does not mean I am going to give you the answers. In fact, I will not show you any code, but rather I will expain things in full detail.
shanebo2003
08-09-2007, 01:36 PM
Haha - I am totally for that....thanks for your help, and i will be looking forward to your response...
shanebo2003
08-14-2007, 04:29 PM
So.......here we are........
BillyGalbreath
08-14-2007, 07:30 PM
Crap.. So sorry - I completely forgot about this thread... I'll reply back tomorrow after I go over the code again.
shanebo2003
08-16-2007, 11:48 AM
It hurts to know that I am so forgetful...
shanebo2003
08-21-2007, 04:45 PM
....Billy?
BillyGalbreath
08-21-2007, 04:56 PM
Hey shane. Sorry about the long delays..
I loked over the code, and it's going to be alittle more difficult that i anticipated. I am having to learn coothead's script inside and out before I can make such a modification to it without breaking it somewhere else.
I'll get back to you as soon as I figure something out.
shanebo2003
08-22-2007, 05:44 PM
Sounds good....just keep me posted for now...
eddy9
08-29-2007, 08:40 AM
I know the tool works perfectly....coothead was very helpful!
Here is the problem...whenever the second and third menu choices are chosen and the submit button is hit, I need to pop out a different value than what is actually shown in the menus. For instance, instead of "TSG IT", I need to pop up a code that looks like gibberish. This is why I said it was like the .value an .innerhtml coothead used earlier because I need one thing to show but another to pop out in the output box.
Understand?
Why gibberish ?.
Couldn't you just find the index of each array ?, for example, if it was me and I'm assuming you want the output to lead to another page (probably wrong to assume) I'd take the easy option and add the following to the display function.
<script type="text/javascript">
// new var at the top
var Output='';
..
function displayValues() {
code=df[0].value+' - '+df[1].value+' - '+df[2].value;
df[3].value='';
// if the three dropdowns are not equal to nothing then display
if((df[0].value!='')&&
(df[1].value!='')&&
(df[2].value!='')){
df[3].value=code;
//get array positions
Output = numbers.indexOf(df[1].value) + "" + letters.indexOf(df[2].value);
// alert output and df[3] value
alert(code + "\nOutput : " + Output);
// redirect to page based on number output
window.location="/wrkgrp.asp?page"+Output;
}
}
as I say, I'm assuming, still, just a thought.
shanebo2003
09-04-2007, 04:50 PM
Thanks for the input!
I say "gibberish" because I am not wanting the output box to display what is in the drop-down menus, but rather a code that points to these. For instance, once all three menus are selected, instead of the output reading "#1 - #2 - #3", I need it to read something completely different - so I just need to be able to display one value in the drop down menus and have another value pop out in the output field.
Make sense?
eddy9
09-05-2007, 05:44 AM
I see, the quickest way is to add a new output array to coincide with the letters array.
Edit:
missed the numbers (Noutput) array
8660
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.