rado
Posts: 221
|
| Posted: 06/10/2009, 6:47 PM |
|
I would like to make a page where on the left side will be search box with fields:
listbox (country)
listbox (province)
listbox (city)
On the right side I will have clickable map and what I would like to know is how I can make that when user click on (for example) "Canada" map, that in same time the listbox (country) will be updated with selection from maps. And so on. If user click on province (for example) Ontario the listbox (province) should be updated with selected province "ontario.
I have no problem to make the whole page, but I don't know how to synchronize the selection between map and listbox. I guess the js should be used for this. If anybody could point me to right direction it will be great
Thanks,
Rado
|
 |
 |
melvyn
Posts: 333
|
| Posted: 06/10/2009, 8:28 PM |
|
Your country listbox must look like this:
<select name="countries" id="listbox-country">
<option value="ca">Canada</option>
<option value="us">United States</option>
<option value="do">Dominican Republic</option>
</select>
Then you need to set a value for that select. it's easy using jquery or some other library. You need an event in your image:
<img src="/images/countries/canada.jpg" onclick="javascript:setCountry('ca');">
The plain javascript is:
function setCountry(country){
document.getElementById("listbox-country").setAttribute("value",country);
}
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
jjrjr1
Posts: 942
|
| Posted: 06/10/2009, 10:55 PM |
|
Hi
I might misunderstand what you are needing here.
I am assuming you would like this to be maintainable in CCS and you do not have individual images for each country / province or state.
Let me know if that is true.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
rado
Posts: 221
|
| Posted: 06/11/2009, 5:26 AM |
|
Thanks Melvyn,
Since my control source for search box is tables (countries, states), do I still need to specify values in HTML for listboxes (countries, states). Probably yes, but in case that I have world map, then I need to list the whole contents of "countries and states" tables in html. Is that right?
Since I work with PHP which library you suggest to use to set a value for select. I never did it before. Do you have any example how to do that?
=============================================
jjrjr1, thanks for reply.
Yes, I would like this to be maintainable in CCS and I have individual images for every country and province.
Rado
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 06/11/2009, 5:36 AM |
|
With individual images for each country, state, province, Melvyn's method will work. (although I would make them image links and set the url to javascript:setCountry("value",country) This way the links can be maintained in the CCS IDE
If using one map image showing all the countries, provinces, and states the approach would be a little different.
Also for maintainability, create the list box in the CCS IDE and point to a DB table for the values. Then in the id property set tha value you want for the DOM element of that listbox.
This way your page will be maintainable in CCS and reduce the amount of custom code needed.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
rado
Posts: 221
|
| Posted: 06/11/2009, 6:32 AM |
|
Thanks a lot.
Rado
|
 |
 |
|