Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Javascript problem: Undefined variable

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
Watch

Shad

New Member
Impact
0
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!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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.
 
0
•••
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!
 
0
•••
you could also use the nl2br fucntion
 
0
•••
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back