how to display data in html - html

In my project, I am retrieving an address from the database and displaying this address on page. The issue or problem that I am facing is the the way the retrieved address is being displayed.
Basically this is the way the address is being displayed:
Address: 1 Kings Street Kilmarnock East Berkshire Scotland KA1 UIT
I would like the address to be displayed like so:
Address: 1 Kings Street
Kilmarnock
East Berkshire
Scotland
KA1 UIT
How can I do this in HTML or css? I am currently using twitter bootstrap , and I don't if there is anyway to do using it.

Oh.. It's hard but let me try... ;)
<div>Address: 1 Kings Street<br> Kilmarnock <br>East Berkshire<br> Scotland <br>KA1 UIT</div>
Your Expected Output:
Address: 1 Kings Street
Kilmarnock
East Berkshire
Scotland
KA1 UIT
Working Demo
Note: This is just simplest and basic way.. But if Data is coming from any database dynamically then at-least you should explain in details from where it comes and by which object it can be accessible.. Then you can apply JS or regex functions... I hope you understand what I mean..

If you edited the data in your database, and used a comma between each line, you might be able to split the data. (your question doesn't state what language you are writing in (mvc/how data is being received).
However, once you have the string, you can use the String.split method (available in most languages), and hence could adapt your view accordingly.
So,
Address: 1 Kings Street, Kilmarnock, East Berkshire, Scotland, KA1 UIT
would become
{1 Kings Street}{ Kilmarnock}{ East Berkshire}{ Scotland}{ KA1 UIT}
which you could then do a foreach block, displaying them onto the screen as you requested
A possible alternative (although probably not easy), would be to extract the postcode, and call a google maps API call to receive the address - but again, this would be quite difficult.
At present, I cannot see how you would be able to expect a program to decide where to split the address into separate lines (unless you place them into different fields which was described in the comments).

You can add <p> to each line, or put <br> at the end of each lines.
But
If your retrieving the data from a database through a php variable you cannot do that with pure html / css, you'll need string manipulation with PHP.

Related

Chrome Devtools, copying over a set of answers

I have to do this repeatedly, so I was wondering if there was a working around....
here is a set of amenities for an apartment, they have to be transferred to a larger list containing those amenities by clicking off multiple choice cirlces. Is there away to edit the script to do it all at once>
example
accessible
air conditioning
dishwasher
garage
hardwood floors
parking
patio / balcony
gym
in unit laundry
cats allowed
dogs allowed
pet friendly
basketball court
bathtub
bbq/grill
bike storage
business center
carpet
ceiling fan
clubhouse
game room
granite counters
microwave
oven
package receiving
playground
pool table
range
refrigerator
stainless steel
walk in closets
I think you want to just checkmark all of the checkboxes on the amenities list so something like this will work:
$('div.whitelist-searchable-amenity input[type=checkbox]').each(function(){
$(this).prop('checked', true);
});
https://jsfiddle.net/r62qgou3/
Edit:
I am not sure of what you mean by "copying text to script" but I modified the script to check if the values that you are looking for are within the document. This should search the values of the checkboxes and then you can use your own script to "copy" the value elsewhere. Just add more values to the array if you need more keywords.
x = [
"accessible",
"air conditioning",
"dishwasher",
"garage",
];
$('div.whitelist-searchable-amenity input[type=checkbox]').each(function(){
if(x.indexOf(this.value) > -1)
{
alert("copy here");
}
});

How to search for all points inside multi polygons which have intersect?

I am working with spatial object in MySQL. I have a table that saves the location of estate in database as "longitude" and "latitude", and I search for these estates inside of polygons that user requests. I am using the st_contains function in MySQL, like this:
select * from estate where ST_CONTAINS(GEOMFROMTEXT(region),POINT(plat,plon)));
In the code snippet region has this format:
"POLYGON((lat1 lng1,lat2 lng2,lat3 lng3,lat4 lng4,lat1 lng1),(lat6 lng6,lat7 lng7,lat8 lng8,lat9 lng9,lat6 lng6))"
Everything works well when polygons have no overlap with each other. However, if polygons have overlap, MySQL subtracts that overlap area and does not retrieve estates in the overlap area. I add this image for more explanation:
How do I make this search work correctly, even with overlapped polygons?
In MySQL, we have the type MULTIPOLYGON for this situation. You can see complete document in MySQL Spatial Data Types.
Your region will need to be defined like this:
"MULTIPOLYGON(((lat1 lng1,lat2 lng2,lat3 lng3,lat4 lng4,lat1 lng1)),((lat6 lng6,lat7 lng7,lat8 lng8,lat9 lng9,lat6 lng6)))"

UITextView: Replace Special Characters [duplicate]

in xml data is
<content_special>
SAT 17TH TEST test club cheap drinks £3 shots £5 bottles $beers
</content_special>
i get this string using this code
TBXMLElement *Content_Special=[TBXML childElementNamed:#"content_special" parentElement:Club];
NSString *Content_SpecialStr = [TBXML textForElement:Content_Special];
when i NSLog(#"Content_special:%#",Content_SpecialStr);
that print like this
Content_special:SAT 17TH TEST
test club
cheap drinks
£3 shots
£5 bottles
$beers
how can i get original sting which Display in Xlm ? Any suggestion...
Found Solution Using Google Toolbox for Mac GTMNSString+HTML.h ,GTMNSString+HTML.m And GTMDefines.h,
First #import "GTMNSString+HTML.h"
use like This: Content_SpecialStr = [Content_SpecialStr gtm_stringByUnescapingFromHTML];
Ensure your data xml file has utf-8 encoding http://www.w3schools.com/xml/xml_encoding.asp

Select all text before <br>

I have the following awful HTML:
<p>
102036 - <em>In re</em> State v. Williams video<br>
104236 - University of Kansas Hosp. Auth. v. Board of Wabaunsee County Comm'rs video
</p>
I want to use XPath to capture all of the text following each </a>, so:
Item 1: " - In re State v. Williams
Item 2: " - University of Kansas Hosp. Auth. v. Board of Wabunsee County
Alternatively, I could just capture all text, and that would be fine too:
Item 1: "102036 - In re State v. Williams
Item 2: "104236 - University of Kansas Hosp. Auth. v. Board of Wabunsee County
I've been trying various things for a while now, but making no progress. I want something like:
/a/following::text()[before::br]
Help?
Here you go, pal:
//a//following-sibling::text() | //a//following-sibling::*[not(self::a)]/text()
The best thing I've found so far is to simply nuke the errant <em> nodes.
So:
elem = html.xpath('//p')[0]
etree.strip_tags(elem, 'em')
Then, using the cleaner html, a simple XPath can be used:
texts = [e.tail for e in elem.xpath('//a')]
Credit where due: https://stackoverflow.com/a/8788559/64911
If you have firebug installed and are running Firefox, for this and all future xpath needs you can just follow this tutorial:
http://www.wikihow.com/Find-XPath-Using-Firebug
Very easy way to find the xpath for anything on a page.

HTML String in JSON

I know it isn’t the best idea to have html in your JSON but sadly I am not in control of this database or this website and am not given those privileges! I am making google maps markers and one of the values is corrupting the data and not being processed right. I know the issue is in the DESC value, is there some sort of character that isn’t escaped? Because almost all of the other objects in the JSON work just fine besides this one.
{"PHONE":"847-509-2000”,
"LAT":42.15223,
"STATE":"IL”,
"ZIP":60015.0,
"NAME":"DC Sarnies”,
"DESC":"Opening in early May 2011, D.C. Sarnies is a contemporary but casual restaurant
specializing in sandwiches and classic American food with a twist. As well as a
restaurant, we serve as a research and development kitchen for its parent company,
Highland Baking Company. Guest chefs and bakery clients will have the opportunity to try
out new products and let diners provide feedback on the dishes. The menu at D. C. Sarnies
has something for everyone with a wide variety of appetizers, soups, salads, entrees and
signature sandwiches and burgers to choose from. A full bar also gives diners a wide range
of craft beers including more than 25 on tap, wine and cocktails. For more information
visit us on Facebook at D.C. Sarnies or on Twitter DC_Sarnies.”,
"LONG":-87.84241,
"CITY":"Deerfield”,
"ADDR":"649 Lake Cook Road”,
"PHOTO":"DCcrabcakeburger.jpg”}]
jsonlint error message: Parse error on line 74:
...02, "DESC": "Opening in early Ma
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
http://jsonlint.org/ use this website to validate your JSON.
The problem here are the closing quotes you use for strings, they're invalid.
End double quotes wrong. Rest everything is fine and working.
The double quotes at the end of the values are the problem. They're the wrong character.
There are a couple issues:
Different quotes used. ” is different from ".
Multi-line isn't escaped. If you need the line breaks, use \n. Otherwise, just have it one line
The extra ] at the end shouldn't be there
This is what you should have:
{
"PHONE": "847-509-2000",
"LAT": 42.15223,
"STATE": "IL",
"ZIP": 60015,
"NAME": "DC Sarnies",
"DESC": "Opening in early May 2011, D.C. Sarnies is a contemporary but casual restaurant specializing in sandwiches and classic American food with a twist. As well as a restaurant, we serve as a research and development kitchen for its parent company, Highland Baking Company. Guest chefs and bakery clients will have the opportunity to try out new products and let diners provide feedback on the dishes. The menu at D. C. Sarnies has something for everyone with a wide variety of appetizers, soups, salads, entrees and signature sandwiches and burgers to choose from. A full bar also gives diners a wide range of craft beers including more than 25 on tap, wine and cocktails. For more information visit us on Facebook at D.C. Sarnies or on Twitter DC_Sarnies.",
"LONG": -87.84241,
"CITY": "Deerfield",
"ADDR": "649 Lake Cook Road",
"PHOTO": "DCcrabcakeburger.jpg"
}