/    Sign up×
Community /Pin to ProfileBookmark

using HREF in array

Hey, I’m new to Javascript and I’m trying to edit some code on our company website. We have the contact info for our franchises stored in arrays and I want to wrap the phone numbers with <a href=”#” rel=”tel”> so that they’ll appear as links on mobile devices.

I’m just unfamiliar with the syntax and I can’t figure out how to add the <a> to the array without breaking it. Is it even possible?

Here’s an example of the contact info for one of our properties:

[CODE]
contactInfo[“5”] = [“165 Belmont Street<br />Woodland, WA 98674”, “165 Belmont Street, Woodland, WA 98674”, “<b>Tel:</b> 525-225-1355<br /><b>Fax:</b> 525-225-7813”, “<b>Office Hours:</b><br />9:00-5:00<br />Monday-Saturday”, “1716”];
[/CODE]

Thanks in advance

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SockwaveJan 17.2011 — Not sure what the problem is. Can you add the tag manually to each entry, or do you want to do it automatically? If you're concerned about having the quotes inside the <a> tag, use single quotes, i.e.
<i>
</i>contactInfo["5"] = ["165 Belmont Street&lt;br /&gt;Woodland, WA 98674", "165 Belmont Street, Woodland, WA 98674", "&lt;a href='#' rel='tel'&gt;&lt;b&gt;Tel:&lt;/b&gt; 525-225-1355&lt;/a&gt;&lt;br /&gt;&lt;b&gt;Fax:&lt;/b&gt; 525-225-7813", "&lt;b&gt;Office Hours:&lt;/b&gt;&lt;br /&gt;9:00-5:00&lt;br /&gt;Monday-Saturday", "1716"];

If you want to automate it, you'll just have to figure out how to parse the string in contactInfo["5"][3] and add the changes.
Copy linkTweet thisAlerts:
@JPDauthorJan 17.2011 — Thanks. I feel stupid, but yeah, it was the single quotes inside the double quotes. That's what I needed. Like I said, I'm learining ?

Thanks again.
×

Success!

Help @JPD spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...