Initializing
Liveweave
Web
expand_more
home
Home
data_object
CSS Explorer
arrow_outward
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
outbox_alt
Generative AI
arrow_outward
frame_source
Python Playground
New
arrow_outward
build
Tools
expand_more
restart_alt
Load "Hello Weaver!"
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Save
account_circle
Login
settings
Settings
expand_more
14
px
Live mode
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
<title></title> <div class='main'> <h1></h1> <form id="myform" > <div class="contents"> <b>*Select area</b> <p><span>Continent:</span> <select name="continent" id="continent" onchange="getplaces(this.value,'country');"> <option value=""></option> </select> </p> <p><span>Country:</span> <select name="country" id="country" onchange="getplaces(this.value,'province');"> <option value=""></option> </select> </p> <p><span>State / Provice:</span> <select name="province" id="province" onchange="getplaces(this.value,'region')"> <option value=""></option> </select> </p> <p><span>County / Region:</span> <select name="region" id="region" onchange="getplaces(this.value,'city')"> <option value=""></option> </select> </p> <p><span>City:</span> <select name="city" id="city"> <option value=""></option> </select> </p> </div> </form> </div>
.contents { background-color:#EDF4F8; padding:10px; border:2px dashed #C2DAE7; width: 70%; margin: 0 auto; } .contents p span { display:block; float:left; margin-left:0px; width:110px; color:gray; font-weight:bold; } .contents p select { float:left; margin-left:90px; } .contents p { clear:both; overflow:hidden; }
// JSONscriptRequest -- a simple class for accessing Yahoo! Web Services // using dynamically generated script tags and JSON //http://vikku.info/programming/js/geodata-jsr-class.js // Author: Jason Levitt // Date: December 7th, 2005 // // A SECURITY WARNING FROM DOUGLAS CROCKFORD: // "The dynamic <script> tag hack suffers from a problem. It allows a page // to access data from any server in the web, which is really useful. // Unfortunately, the data is returned in the form of a script. That script // can deliver the data, but it runs with the same authority as scripts on // the base page, so it is able to steal cookies or misuse the authorization // of the user with the server. A rogue script can do destructive things to // the relationship between the user and the base server." // // So, be extremely cautious in your use of this script. // // Constructor -- pass a REST request URL to the constructor // function JSONscriptRequest(fullUrl) { // REST request path this.fullUrl = fullUrl; // Keep IE from caching requests this.noCacheIE = '&noCacheIE=' + (new Date()).getTime(); // Get the DOM location to put the script tag this.headLoc = document.getElementsByTagName("head").item(0); // Generate a unique script tag id this.scriptId = 'YJscriptId' + JSONscriptRequest.scriptCounter++; } // Static script ID counter JSONscriptRequest.scriptCounter = 1; // buildScriptTag method // JSONscriptRequest.prototype.buildScriptTag = function () { // Create the script tag this.scriptObj = document.createElement("script"); // Add script object attributes this.scriptObj.setAttribute("type", "text/javascript"); this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE); this.scriptObj.setAttribute("id", this.scriptId); } // removeScriptTag method // JSONscriptRequest.prototype.removeScriptTag = function () { // Destroy the script tag this.headLoc.removeChild(this.scriptObj); } // addScriptTag method // JSONscriptRequest.prototype.addScriptTag = function () { // Create the script tag this.headLoc.appendChild(this.scriptObj); } // // // // // // // var whos=null; function getplaces(gid,src) { whos = src // var request = "http://ws.geonames.org/childrenJSON?geonameId="+gid+"&callback=getLocation&style=long"; var request = "http://www.geonames.org/childrenJSON?geonameId="+gid+"&callback=listPlaces&style=long"; aObj = new JSONscriptRequest(request); aObj.buildScriptTag(); aObj.addScriptTag(); } function listPlaces(jData) { counts = jData.geonames.length<jData.totalResultsCount ? jData.geonames.length : jData.totalResultsCount who = document.getElementById(whos) who.options.length = 0; if(counts)who.options[who.options.length] = new Option('Select','') else who.options[who.options.length] = new Option('No Data Available','NULL') for(var i=0;i<counts;i++) who.options[who.options.length] = new Option(jData.geonames[i].name,jData.geonames[i].geonameId) delete jData; jData = null } window.onload = function() { getplaces(6295630,'continent'); }