Solved

Javascript truncating text in a string

Posted on 2007-12-06
1
2,792 Views
Last Modified: 2012-06-27
I'm returning data that was escaped, I can see the escaped data with the first alert (ie. DESIGN%20DOCUMENTS). I then assign the unescape data to variable desc. The next alert I see the unescape data with spaces (ie DESIGN DOCUMENTS). All is well at this point. Next I build a variable str with HTML using the variable desc to place the value in a text box, this is where it gets truncated, all that gets loaded into the text box is DESIGN not DESIGN DOCUMENTS. Any suggestions. Thanks.
alert(timeq.desc[0]);
     var desc = unescape(timeq.desc[0]);alert(desc);
     str+='<TD width="10%"><input class="sminputbox" style="text-align:right" OnKeyup="chkdols(this);" OnFocus="select();" name="prehrs1" value=' + timeq.hours[0] + ' size="4" maxlength="4"><\/TD>';
     str+='<TD width="30%"><input class="sminputbox" type="text" name="predesc1" value=' + desc + ' size="45" maxlength="150"><\/TD>';
     str+='<TD width="20%" id="preact1">' + timeq.workact[0] + '<\/TD>';
     str+='<TD width="20%" align="center"><img name="saves" id="1" valign="bottom" src="/Graphics/smpost_button.jpg" onClick="SavePre(this);" title="Click to save this transaction for current post date."></TD>';
     str+='<TD width="5%"><\/TD><\/TR><TR>';
document.getElementById("previousspan").innerHTML = str

Open in new window

0
Comment
Question by:headjava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
Sinoj Sebastian earned 125 total points
ID: 20421334
use

str+='<TD width="30%"><input class="sminputbox" type="text" name="predesc1" value="' + desc + '" size="45" maxlength="150"><\/TD>';
     
alert(timeq.desc[0]);
     var desc = unescape(timeq.desc[0]);alert(desc);
     str+='<TD width="10%"><input class="sminputbox" style="text-align:right" OnKeyup="chkdols(this);" OnFocus="select();" name="prehrs1" value=' + timeq.hours[0] + ' size="4" maxlength="4"><\/TD>';
     str+='<TD width="30%"><input class="sminputbox" type="text" name="predesc1" value="' + desc + '" size="45" maxlength="150"><\/TD>';
     str+='<TD width="20%" id="preact1">' + timeq.workact[0] + '<\/TD>';
     str+='<TD width="20%" align="center"><img name="saves" id="1" valign="bottom" src="/Graphics/smpost_button.jpg" onClick="SavePre(this);" title="Click to save this transaction for current post date."></TD>';
     str+='<TD width="5%"><\/TD><\/TR><TR>';
document.getElementById("previousspan").innerHTML = str

Open in new window

0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question