Time:
Scotland: Sat, 12:41 am Rhode Island: Fri, 7:41 pm Florida: Fri, 7:41 pm New Mexico: Fri, 5:41 pm California: Fri, 4:41 pm
Buy this Ad Space. 180px wide. Please get in touch with KH@ if you are interested and make an offer.
US$10 per year - Save $100s! The Fabulously Unfair WebX Auction Bar. For Ebay etc. Ro-Sham-Bo the opposition. Laugh like Eric Cartman when you win! CLICK HERE NOW!More information and sign-up.
WebXpertz Hosting. Custom fit from $5pm. PHP/MySQL You'll save money, we'll save money. Seems fair to me. Interested? If so Please PM me here and tell me what you need. Thanks!
|
For continued disscussion on this topic : double combo box question
dfred 07-12-2001, 09:06 PM I am using the double combo code to create two related select boxes. My issue is that the array needs to be populated from a query. I used cold fusion to populate the 2d array (could not figure that out in js). the script does not work when I select an item in the first box...the second box does not populate. here is the code I am using and what the array looks like:
<input type="button" name="test" value="Go!"
onClick="go()">
</p>
<CFSET temp = ValueList(hgear_part_desig_qn.hgear_part_number)>
<CFSET temp2 = ValueList(hgear_part_desig_qn.hgear_desg)>
<CFSET group= ArrayNew(2)>
<CFLOOP From="1" To="#ListLen(temp)#" INDEX="Counter">
<CFOUTPUT>
<CFSET group[Counter][1] = "#listgetat(temp, Counter)#">
<CFSET group[Counter][2] = "#listgetat(temp2, Counter)#">
</CFOUTPUT>
</CFLOOP>
<cfloop from="1" to="#arraylen(group)#" index="row">
<cfoutput>
#group[row][1]#
#group[row][2]#<br>
</cfoutput>
</cfloop>
<script>
<!--
/*
Double Combo Script Credit
By Website Abstraction (www.wsabstract.com)
Over 200+ free JavaScripts here!
*/
var groups=document.doublecombo.part_number.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
//group[0][0]=new Option("Website Abstraction","http://wsabstract.com")
//group[0][1]=new Option("News.com","http://www.news.com")
//group[0][2]=new Option("Wired News","http://www.wired.com")
//group[1][0]=new Option("CNN","http://www.cnn.com")
//group[1][1]=new Option("ABC News","http://www.abcnews.com")
//group[2][0]=new Option("Hotbot","http://www.hotbot.com")
//group[2][1]=new Option("Infoseek","http://www.infoseek.com")
//group[2][2]=new Option("Excite","http://www.excite.com")
//group[2][3]=new Option("Lycos","http://www.lycos.com")
var temp=document.doublecombo.designator
function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}
function go(){
location=temp.options[temp.selectedIndex].value
}
//-->
</script>
the following is the 2d array:
123456-22 H8555
244455-44 H62347
447777-22 H7457
622222-22 H2137
665544-77 H8889
754444-22 H8337
755557-33 H56547
755566-66 H56R7
774557-22 H3445
777443-44 H567
777455-44 H75347
777777-11 H8477
777777-22 H8477
786557-22 H4444
798877-66 H76556
799887-22 H99766
888877-22 H1616
thanks for the help...this forum has been giving me lots of ideas to figure things out.
DAN
voicebox 07-13-2001, 10:34 AM Hi Dan,
I'm no expert at ColdFusion, but it looks like these lines:<cfloop from="1" to="#arraylen(group)#" index="row">
<cfoutput>
#group[row][1]#
#group[row][2]#<br>
</cfoutput>
</cfloop> aren't actually printing out the correct new Option lines. Try putting this in the <script> section, next to all the commented out lines:
<cfloop from="1" to="#arraylen(group)#" index="row">
<cfoutput>
group[#row-1#][0] = new Option("#group[row][1]#","#group[row][1]#");
group[#row-1#][1] = new Option("#group[row][2]#","#group[row][2]#");
</cfoutput>
</cfloop>
If that doesn't work post the source code that you're getting in the browser.
dfred 07-13-2001, 02:32 PM the following is the output code I got from the browser. I had to change the code you gave me since it did not like the #row-1#. I removed the -1 and the page almost worked. a slight problem, the second box was populated with the first boxes selection and its own selection. it will work, but I don't understand how it populated the second box with the first boxes selection?
I thank you for getting me close and if you see what may be wrong that would be ever better. --dan
here is what I changed you code to:
<cfloop from="1" to="#arraylen(group)#" index="row">
<cfoutput>
group[#row#][0] = new Option("#group[row][1]#","#group[row][1]#");
group[#row#][1] = new Option("#group[row][2]#","#group[row][2]#");
</cfoutput>
</cfloop>
here is the source code from my page:
var groups=document.doublecombo.part_number.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
group[1][0] = new Option("123456-22","123456-22");
group[1][1] = new Option("H8555","H8555");
group[2][0] = new Option("244455-44","244455-44");
group[2][1] = new Option("H62347","H62347");
group[3][0] = new Option("447777-22","447777-22");
group[3][1] = new Option("H7457","H7457");
group[4][0] = new Option("622222-22","622222-22");
group[4][1] = new Option("H2137","H2137");
group[5][0] = new Option("665544-77","665544-77");
group[5][1] = new Option("H8889","H8889");
group[6][0] = new Option("754444-22","754444-22");
group[6][1] = new Option("H8337","H8337");
group[7][0] = new Option("755557-33","755557-33");
group[7][1] = new Option("H56547","H56547");
group[8][0] = new Option("755566-66","755566-66");
group[8][1] = new Option("H56R7","H56R7");
group[9][0] = new Option("774557-22","774557-22");
group[9][1] = new Option("H3445","H3445");
group[10][0] = new Option("777443-44","777443-44");
group[10][1] = new Option("H567","H567");
group[11][0] = new Option("777455-44","777455-44");
group[11][1] = new Option("H75347","H75347");
group[12][0] = new Option("777777-11","777777-11");
group[12][1] = new Option("H8477","H8477");
group[13][0] = new Option("777777-22","777777-22");
group[13][1] = new Option("H8477","H8477");
group[14][0] = new Option("786557-22","786557-22");
group[14][1] = new Option("H4444","H4444");
group[15][0] = new Option("798877-66","798877-66");
group[15][1] = new Option("H76556","H76556");
group[16][0] = new Option("799887-22","799887-22");
group[16][1] = new Option("H99766","H99766");
group[17][0] = new Option("888877-22","888877-22");
group[17][1] = new Option("H1616","H1616");
dfred 07-13-2001, 03:56 PM maybe I should also throw this out...
I am also trying to use this combo box within a loop so that if there are 3 items that need the combo box, the there are three combo boxes. I have tried to set up a loopcounter with each select box name, and this does not get the script to run. not sure why....
DAN
dfred 07-16-2001, 02:08 PM I was hoping since it was monday that people would see this and maybe someone would be able to help me solve an ongoing problem.
Dan
lorddog 07-16-2001, 03:35 PM wheres the source code of the combo boxes,
perhaps with that we can tell something.
Lorddog
dfred 07-16-2001, 03:49 PM I added the source code as a text file. I looped the file through a madeup list 3 times. here is the error that is displayed when it tries to loop through.
document.doublecombo.part_number.options is null or not an object
the part_number needs a loopcounter to increment the name I think.
hope this helps
Dan
dfred 07-16-2001, 08:06 PM I know someone out there has done something similar to this. I have been racking my newbie brain for days and cannot seem to get it. I have even found other forums to try and got some input but not helpful enough. Please someone help me!!
lorddog 07-16-2001, 08:16 PM *******************
first error I see is
for (i=0; i<groups; i++)
should probably be more like
for (i=0; i<groups-1; i++)
*
*no now that I look at this I am wrong and you had it right.
*edited by lorddog
***********************
and I see repeated variables and functions (same name)
in that source code. you should only have either one array built and function or use different names each time it is used.
this page doesn't work at all. and I am not entirely sure what you are trying to do.
Lorddog
*also I see you are missing </select> in some of them and you need that
dfred 07-16-2001, 08:49 PM I am a real new user of JS and don't know a lot about it. the page i am displaying is a sample of a larger page.
There is a page where the user will select how many items to ship. this page is submitted to the main page and the main page loops through to display the combo box for as many times as selected on the first page.
example first page select 5
second page loops through and displays 5 combo boxes.
each combo box select box will be named part_number and designator. for each loop through these names need to have a 1 or 2 or 3 or 4 or 5 appended to the end of the names.
then the boxes are populated through query data.
I hope this helps and you can help me.
dan
lorddog 07-16-2001, 11:53 PM change those things I pointed out.
you are gonna need in cold fusion a global variable starting at
0 and incrementing every time you make the combo.
you may/ or may not need to make as many functions. if they are all alike then you should take it out of the combo making stuff and put it once at the top of the page(between the head tags in script tags).
each time you build a combo, increment that global var and tag it onto the variables. I can't help in CF as I don't know it at all. But I can help you with the IDEA of the way to build your pages. Then you can use that and add the CF syntax.
Lorddog
dfred 07-17-2001, 02:52 PM thanks for the reply. I figured that a variable needed to be set up. In Cold Fusion I set a loopcounter which works with the loop but does not work with javascript. how can I set a looping variable so i can set part_number + j like shown below. if i can get the j to increment, then I think the rest of the code may work or at least be close.
example code:
var sel = document.doublecombo.elements["part_number" + j];
//var groups=document.doublecombo.partnumber.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
thanks
dan
lorddog 07-17-2001, 04:08 PM I think you need to do those variables in CF
so something more like
var groups#j#=document.doublecombo.part_number#j#.options.length
var group#j#=new Array(groups#j#)
for (i=0; i<groups#j#; i++)
group#j#[i]=new Array()
then each just before each time you do a new loop increment the #j#
Lorddog
dfred 07-17-2001, 04:26 PM I know your not a CF guy so I thank you for trying to help. the js code does not understand what the ## is. an error pops up saying invalid character. That is why I thought I may have to set the value in js. I am just lost...i think i am close, but not there yet.
Dan
dfred 07-17-2001, 05:44 PM does anyone else have an idea for me. even if you do it all in js and have no Cold Fusion. Anyway to do this would help.
DAN
vBulletin® v3.6.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.
|