/    Sign up×
Community /Pin to ProfileBookmark

Encoding double quotes

function copytable(){
tabvalue=document.getElementById(‘tabvalue’);
var temp=escapeURIComponent(document.getElementById(‘tab’).innerHTML);
tabvalue.value=temp;
//alert(tabvalue.value);
}

I need to copy a table html code inside div tag ‘tab’. Then i am copying the value to a hidden input tabvalue and sending it to a jsp. The problem I am facing here is that,the table line is like this in html page,

<table border=”2″>

but when it is copied to the hidden value,it loses the double quotes,

<table border=2>

I need to pass this double quote too with the string and get it in my jsp for processing.How can i do this? Please help.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorSep 13.2011 — The problem is that[B] innerHTML[/B] returns different syntax in different browsers. In fact, among all the browsers in use, only IE7 and IE8 do not return the double quotes in innerHTML value. I am afraid there is nothing you can do about that. That is the browser's interpreter, so blame MS for have done it that way.

You should probably send only the values to the server-side code, and instruct that server-side code to recreate (re-write) the HTML code as you wanted to be.
Copy linkTweet thisAlerts:
@ruby10authorSep 13.2011 — Thanks for the explanation.What might be the efficient way to reconstruct the HTML again?

My code flow is , I am generating this HTML page.I need only a part of the page for processing in return.I need those quotes because the other part of server code is expecting the HTML fragments in XHTML specification.

If i write an intermediate part, what could be the efficient way to reconstruct the HTML parts?
×

Success!

Help @ruby10 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 6.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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...