/    Sign up×
Community /Pin to ProfileBookmark

inserting line breaks in an array

Hi All,

I have created an events calendar using HTML tables. I added a small javascript to it so that when a person clicks on a date, the results show up in a textarea box. The problem I am having is that the results are displaying on one line, and I would like to break the line so that the date could be on one line and the event on the next. Does anyone know how to insert a line break in an array, or would i have to do it another way?

here is the array and function:

dayEvent= new Array
dayEvent[2] = “9/2 – Zoo Trip – Event Sponsor”
dayEvent[6] = “9/6 – Gold Star – Event Sponsor”
dayEvent[7] = “9/7 – Autumn Festival – Event Sponsor”
dayEvent[11] = “9/11 – Gold Star – Event Sponsor”

function showDate(thisDay)
{
document.Calendar.dateInfo.value = dayEvent[thisDay]
}

The table calls the function in an “href”:
<table>
<tr>
<td><a href=”javascript:showDate(2)”>2</a></td>
</tr>
</table>

Can I replace the dashes in the array elements with a line break? I’d like each on a new line. If so, what is the syntax?

THANKS!! 😮

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERSep 07.2006 — Try:

dayEvent= new Array

dayEvent[2] = "9/2 - nZoo Trip n- Event Sponsor"

dayEvent[6] = "9/6 - nGold Star n- Event Sponsor"

dayEvent[7] = "9/7 - nAutumn Festival n- Event Sponsor"

dayEvent[11] = "9/11 - nGold Star n- Event Sponsor"
Copy linkTweet thisAlerts:
@chqdznrauthorSep 07.2006 — [B]Thanks JMRKER[/B]! I thought to use the "n", but I wasn't sure if I could put it inside the quotation marks in the array -- I thought it would display as text.

It works great!!!
Copy linkTweet thisAlerts:
@JMRKERSep 07.2006 — Glad I could help. I just got to it before someone else did.
×

Success!

Help @chqdznr 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.17,
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,
)...