string capacity

This is a discussion on "string capacity" within the JavaScript Forum section. This forum, and the thread "string capacity are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 21st, 2006, 18:36
Junior Member
Join Date: Mar 2006
Age: 21
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
string capacity

Hi, I have a small Javavscript function which recieves some text and a table cell ID (both PHP variables). On mouseover the text is displayed in the specified cell. This is ok if the length of the text string isn't too long but over a certain length the text isn't displayed. How do i specify the length of the string the Javascript can handle?
My function is:-

function display(text,cell){
var getText = document.getElementById(cell).innerHTML += text;
}

Thanks

Don
Reply With Quote

  #2 (permalink)  
Old Sep 21st, 2006, 21:28
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: string capacity

There seems to be a bit of confusion here when you say the function receives two parameters that are php variables.

JavaScript happens client-side and php happens server-side.

Where does the text originate from whose length you want to control.

You should be aware of a cross browser problem with the way you are doing things. It's my understanding that Firefox has a problem with innerHTML when it comes to table cells.
Reply With Quote
  #3 (permalink)  
Old Sep 22nd, 2006, 01:55
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: string capacity

JavaScript can't read PHP variables. If you'd tell us a little more about what you're doing, we'll be happy to help find a solution, though.
Reply With Quote
  #4 (permalink)  
Old Sep 22nd, 2006, 08:14
Junior Member
Join Date: Mar 2006
Age: 21
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: string capacity

Maybe I should have included this line of PHP which calls the function with the php variables $text and $cellID.

echo "<a href='$location' onmouseover='display(\"$text", \"$cellID\")'>$link</a>";

Here's the function again: -
function display(text,cell){
var getText = document.getElementById(cell).innerHTML += text;
}

The code works apart from the described string length problem.

Thanks

Don
Reply With Quote
  #5 (permalink)  
Old Sep 22nd, 2006, 08:37
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: string capacity

Hmm. That's odd, I don't think there's a max string length. How long are these strings?
Reply With Quote
  #6 (permalink)  
Old Sep 22nd, 2006, 20:21
Junior Member
Join Date: Mar 2006
Age: 21
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: string capacity

The cut off point seems to be approx 100 characters.
Reply With Quote
  #7 (permalink)  
Old Sep 22nd, 2006, 21:09
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: string capacity

Could you echo the text produced by the php code to the screen seperately so we can tell whether its php or on the html page where the text is being abreviated.
Reply With Quote
  #8 (permalink)  
Old Sep 23rd, 2006, 00:20
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: string capacity

Which browser(s) are you testing in? As Geoff said, it could be a browser thing.
Reply With Quote
  #9 (permalink)  
Old Sep 23rd, 2006, 08:54
Junior Member
Join Date: Mar 2006
Age: 21
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: string capacity

Not sure what you mean by echoing to the screen but here's what's echoed. I'm using Firefox.

echo "<td width ='50%' >\n";
echo "<a href='$location' onmouseover='display(\"$text", \"$cellID\")'>$link</a>";
echo "</td></tr>\n";
echo "<td width='50%' id = '$cellID'></td></tr>\n";
Reply With Quote
  #10 (permalink)  
Old Sep 23rd, 2006, 13:47
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: string capacity

Just for debug purposes, add this line of code and then you will be able to read the value on screen. Depending where in your php you put it it might displace your layout but that's the price of debugging.
Code: Select all
print ("<b />".$text."<b />");
Lets see what you have.
Reply With Quote
  #11 (permalink)  
Old Sep 23rd, 2006, 14:48
Junior Member
Join Date: Mar 2006
Age: 21
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: string capacity

I put 'print ("<b />".$text."<b />"); ' before the table, in the table and after the table, each time the full string shows. Thanks for your help so far by the way, much appreciated.
Reply With Quote
  #12 (permalink)  
Old Sep 23rd, 2006, 20:28
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: string capacity

Ok, so we know that php isn't cutting your string short so it's happening client-side.

I'd like you to try a different browser and see if the same thing happens.
Reply With Quote
Reply

Tags
string, capacity

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
timestamp in string to int CloudedVision PHP Forum 1 Apr 3rd, 2008 17:10
Get value from SQL string ? VegaLA Classic ASP 5 Jan 30th, 2008 07:39
capacity of a div. asp.net shamail ASP.NET Forum 0 Aug 20th, 2007 20:59
website capacity? cj550 Hosting & Domains 4 Mar 18th, 2007 19:01
append % to the string chandra.nowduri ASP.NET Forum 1 Aug 9th, 2006 09:47


All times are GMT. The time now is 11:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43