English 中文(简体)
如何在javascript中过滤数据和人口化 com箱
原标题:How do i filter data and populate combobox in javascript

I am thinking to work on two combos for: country and city.

当用户在一只 com船中选择国家时,其城市应居住在城市 com带。

For it:
1.) Prepare 2 javascript variables: first one with countries id and name, second one with cities id, name and country_id

For Countries:
[
{"id":1, "title":"uk"},
{"id":3, "title":"US"},
{"id":6, "title":"CANADA"},
{"id":8, "title":"AUSTRALIA"}
]

and For Cities:
[
{"id":1, "country_id":1, "city":"LONDON"},
{"id":3, "country_id":1, "city":"Manchester"},
{"id":4, "country_id":2, "city":"New YORK"},
{"id":5, "country_id":2, "city":"New Jersey"},
{"id":8, "country_id":8, "city":"MELBOURN"}
]

Now:
1.) How do i populate the above country data to country combobox?
2.) How do i populate the related cities data to the city combobox when user selects the country?

问题回答

My Man I Love Pure Javas

名单 页: 1

首先,这是一种 j子物体的权利,因此,如果使用电子阀功能进行扼杀,你就有必要加以揭穿。

var jsonobject = eval(json string);

然后通过该物体进入dl

......

那么,它就象这样说了。

用于装满 d子和装饰内

var ddl_countries= document.getElementById( countriesdropdownid ) var ddl_country_option = document.createElement( option ); ddl_country_option.innerHTML = text //from the object; ddl_country_option.value = value //from the object; ddl_countries.appendChild(ddl_country_option);

对城市具有约束力的措施

如果你要求提供更多描述的iam,仅能告诉我,我会相互交错,而且我会写出完整的法典,那么对城市来说,变化是一样的。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签