<select style="width: 512px; height: 228px;" id="lstMatches" size="4" name="lstMatches">
<option value="1 Corn Exchange, The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM">1 Corn Exchange, The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM</option>
<option value="2 Corn Exchange, The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM">2 Corn Exchange, The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM</option>
<option value="3 Corn Exchange, The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM">3 Corn Exchange, The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM</option>
<option value="2 The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM">2 The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM</option>
<option value="3 The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM">3 The Strand, RYE, East Sussex, TN31 7DB, UNITED KINGDOM</option>
</select>
<div id="add"></div>
JavaScript
$(document).ready(function () {
$('select').click(function () {
var selected = $(this).find(':selected').text();
var substr = selected.split(',');
var country = substr[6];
var postcode = substr[5];
var county = substr[4];
var city = substr[3];
var addthree = substr[2];
var addtwo = substr[1];
var addone = substr[0];
//DO SOMETHING WITH IT??
$('#add').html
('<input value=\"'+ addone + '\" id=\"addr_address1\" readonly=\"read-only\"><input value=\"'+ city + '\" id=\"addr_city\" readonly=\"read-only\"><br><input value=\"'+ addtwo + '\" id=\"addr_address2\" readonly=\"read-only\"><input value=\"'+ county + '\" id=\"addr_county\" readonly=\"read-only\"><br><input value=\"'+ addthree + '\" id=\"addr_address3\" readonly=\"read-only\"><input value=\"'+ postcode + '\" id=\"addr_postcode\" readonly=\"read-only\"><br><input value=\"'+ country + '\" id=\"country\" readonly=\"read-only\">');
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.