/    Sign up×
Community /Pin to ProfileBookmark

escaping HTML characters

Hello, this may be a basic question. 😉

I am trying to escape some basic HTML that is saved to a variable.

[CODE]
// default HTML text
var i=1;
var t_defaultHTML=”<table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”0″>
<tr>
<td>
” + i + “.)
</td>
<td>
<input name=”|_” + i + “-pw_title” value=””>
</td>
<td>
<input name=”|_” + i + “-pw_user” value=””>
</td>
<td>
<span class=”error”>*</span> <input name=”|_” + i + “-pw_pass” value=””>
</td>
</tr>
<tr>
<td colspan=”4″>
<span class=”error”>*</span><textarea name=”|_” + i + “-pw_notes” cols=”60″ rows=”2″>Notes</textarea>
</td>
</tr>
<tr>
<td colspan=”4″>
<div class=”rule”></div>
</td>
</tr>
</table>
“;
[/CODE]

The error I get when accessing the function with this code in it is:

[QUOTE]

Error: unterminated string literal
Source File: [url]http://10.0.1.51/~dbrooke/psswd/edcvault.dna?f_page=AddRecord[/url]
Line: 118, Column: 18
Source Code:
var t_defaultHTML=”<table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”0″>

[/QUOTE]

What is the best way to encode this kind of text/html?

Thanks,
Donovan

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@PadonakJun 25.2010 — [CODE]<script language="JavaScript" type="text/javascript">
<!--
var i=1;
var t_defaultHTML = "<table width='100&#37;' border='0' cellpadding='0' cellspacing='0'><tr><td>" + i + "</td><td><input name='|_" + i + "-pw_title' value=''></td><td><input name='|_" + i + "-pw_user' value=''></td><td><span class='error'>*</span> <input name='|_" + i + "-pw_pass' value=''></td></tr><tr><td colspan='4'><span class='error'>*</span><textarea name='|_" + i + "-pw_notes' cols='60' rows='2'>Notes</textarea></td></tr><tr><td colspan='4'><div class='rule'></div></td></tr></table>";
//-->
</script>[/CODE]
Copy linkTweet thisAlerts:
@EDCauthorJun 25.2010 — Thanks.. very helpful. - Donovan
×

Success!

Help @EDC 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.19,
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,
)...