?
Solved

Javascript truncating text in a string

Posted on 2007-12-06
1
Medium Priority
?
2,795 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 500 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

777 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