NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page javascript problem: undefined variable

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 06-27-2005, 11:05 AM THREAD STARTER               #1 (permalink)
New Member
Join Date: Apr 2005
Posts: 6
Shad is an unknown quantity at this point
 



javascript problem: undefined variable


hey guys,

ive recently been playing around with javascript, and have had no problems, until now. it is quite a wierd problem. for example, when i define a variable:


Code:
var quoteuser_24=new Array()
quoteuser_24[0]='[something]example .......[/something]'
this would have no problem, however if i do this:

Code:
var quoteuser_24=new Array()
quoteuser_24[0]='[example]<?
?>
[/quote]'
this would have the error "undefined". im thinking it is the linebreak in the variable. Is there any solution to this so that i may use linebreaks in variables? My objective as you may have noticed is to insert the variable into a value onClick.

Help apreciated!
Shad is offline  
Old 06-27-2005, 12:41 PM   #2 (permalink)
NamePros Member
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 127
eagle12 will become famous soon enougheagle12 will become famous soon enough
 



It is the newline that you are doing that is causing the problem. Why do you need a newline anyway? You can re-write the code like this:

Code:
quoteuser_24[0]='[example]<?\n?>\n[/quote]'
the "\n" will give you a new line in the string.
eagle12 is offline  
Old 06-27-2005, 12:46 PM THREAD STARTER               #3 (permalink)
New Member
Join Date: Apr 2005
Posts: 6
Shad is an unknown quantity at this point
 



right, i wasn't sure that when inserting text into a value, \n would insert as a new line.

thanks

but theres the problem that i am getting the variable from MySQL in PHP.
and when there are line breaks in the database, how would you convert them into "\n"
i tried using $subject = str_replace("\n","<br>",$subject); however, the linebreaks still apear on the variable. not really sure what to do.

oh. i sorted the problem out, silly mistake =\

thanks for the help!
Shad is offline  
Old 08-20-2005, 05:44 AM   #4 (permalink)
NamePros Regular
 
Zubair1's Avatar
Join Date: Mar 2005
Posts: 912
Zubair1 is just really niceZubair1 is just really niceZubair1 is just really niceZubair1 is just really niceZubair1 is just really nice
 


AIDS/HIV
you could also use the nl2br fucntion
__________________
Live Support : Zubair11 [at] hotmail.com
Free SEO Directory! || Free Online TV || Tech Blog
Web Design & Web Development Services || Reliable Web Hosting
Zubair1 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
read ms access database and store in javascript variable Niko2005 Web Design Discussion 0 05-25-2005 05:40 PM
read ms access database, store value in javascript variable Niko2005 Programming 0 05-15-2005 09:37 PM
Javascript novice with small problem... martyn187 Programming 2 05-04-2004 07:22 AM
Javascript: W3C Problem? Mp)Tarh Programming 2 11-16-2003 05:26 AM
JavaScript Popup Problem successgold Programming 1 09-20-2003 04:01 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 06:30 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger