I just looked at it again, and realized my mistake. I had you put
additional_driver (singular) as the class on each table and then
wrote .additional_drivers (plural) in my function code. I would just
change the function to singular, it’s less code to go through and
change.
Walter
On May 1, 2010, at 5:39 PM, Bob Y wrote:
Walt, Its not quite working. For the drivers list which I clicked to
select it, I put Item/Extended-New and entered for both the Name and
Value - id additional_drivers (exactly like that) and for the
vehicle list I entered - additional_vehicles ID (exactly like that).
For the drivers 2,3 and 4 tables in the Item/Extended New - Name and
Value - I entered class additional_driver (exactly like that) and
for the vehicles 2,3,and 4 tables I entered additional_vehicle class
(exactly like that). Now after applying the Protaculous Action and
entering the code that I copied and pasted exactly as you sent it in
the top Function Body section, I then published and uploaded it and
all of the drivers were still visible but the vehicles had been
hidden like I had hoped. Here’s the link http://dsmithins.com/autoinsurancequo.php
For the heck of it, I added the other code by copy and paste into
the same Function Body and when I looked at the web site all of the
drivers and vehicles were showing again. I believe that I did
everything correctly. Let me know what to try next. Thanks, Bob
Walt, I removed all of the s’s in the code that I could find as far as the words driver and vehicle goes and all the s’s in all of the extended fields in the form but it still looks the same.
How is it that the drivers won’t hide and yet the vehicles do hide and the vehicles appear to hide with the s’s in the code or without the s’s? You said this was going to be a bit tricky and I now know what you mean. I must be doing something wrong.
Thanks Dave, I separated the Name id and the Value additional_driver and it appears to be good but when I select additional Drivers from the menu list it doesn’t show any more drivers or vehicles.http://dsmithins.com/autoinsurancequo.php
Take a look
All right, guys. This may teach me not to type stuff without testing it first. (Probably not, but hey…)
var drivers = function(){
var count = $F('additional_drivers');
$$('.additional_drivers').each(function(elm,idx){
if (idx < count){
elm.show();
}else{
elm.hide();
}
});
};
var vehicles = function(){
var count = $F('additional_vehicles');
$$('.additional_vehicles').each(function(elm,idx){
if (idx < count){
elm.show();
}else{
elm.hide();
}
});
};
drivers();
vehicles();
$('additional_drivers').observe('change',drivers);
$('additional_vehicles').observe('change',vehicles);
With this, you can also delete the other block of code – because this will hide or show based on the value of the pickers, and it runs when the page loads.
For the technically-minded, the reason the other one didn’t work was that I thought (incorrectly) that the include() function worked the same way as the each() function, in that it would pass the index of the loop into the iterator function. It doesn’t. So each() it is.
Walt, I can’t thank you enough for helping me with my Insurance Form, the form works perfectly now. It’s a good thing that there are people like yourself out there willing to help us novices. I’ve learned so much about forms with your taking me step by step that I believe I can upgrade my status from novice to Novice with a capital N. Ha!Ha! I’ll converse with you in the future next time I need some schooling. Once again THANKS, Bob Y.