[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 06-27-2005, 10:05 AM   #1 (permalink)
New Member
 
Join Date: Apr 2005
Posts: 6
12.00 NP$ (Donate)

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, 11:41 AM   #2 (permalink)
NamePros Member
 
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 91
80.80 NP$ (Donate)

eagle12 is on a distinguished road


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, 11:46 AM   #3 (permalink)
New Member
 
Join Date: Apr 2005
Posts: 6
12.00 NP$ (Donate)

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, 04:44 AM   #4 (permalink)
NamePros Regular
 
Zubair1's Avatar
 
Join Date: Mar 2005
Posts: 874
159.45 NP$ (Donate)

Zubair1 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 Games and Songs || eBloggy.net
Zubair.info || Mixcat Interactive
Zubair1 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
read ms access database and store in javascript variable Niko2005 Web Design Discussion 0 05-25-2005 04:40 PM
read ms access database, store value in javascript variable Niko2005 Programming 0 05-15-2005 08:37 PM
Javascript novice with small problem... martyn187 Programming 2 05-04-2004 06:22 AM
Javascript: W3C Problem? Mp)Tarh Programming 2 11-16-2003 04:26 AM
JavaScript Popup Problem successgold Programming 1 09-20-2003 03:01 PM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 07:00 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85