Afternoon All
I have some data –
var searchwithin = [
{id:"clearwithin", type:"button"},
{id:"search_radius", type:"select"},
{id:"for_lease" ,type:"checkbox"},
{id:"for_sale", type:"checkbox"},
];
It is going to be showing and hiding informtion dependent on what is clicked (this is only a small fragment of the data.
I have already worked out how to check the type property, what I want to know is the following:
If the type is button, how do I access the id value for that items and then generate a click function so that that uses the id as the name of the button to associate the function with.
Thanks in advance
Phil
First, fix a syntax error in your
searchwithintable by removing the comma after the last item in the table. That will cause an error in IE6/IE7.Then, you can use this code to look through your
searchwithinarray to find theidfor the appropriatetypeand then set a click event handler for thatid.I notice that your table has two entries for
type:checkbox. The above code suggestion will return and operate on the first entry only. If you want to set up click handlers for both those IDs, then either the code or table would have to be modified. If this is all the table is used for, it could be changed to be a selector (which can contain more than one id) like this: