Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Problem with special characters...
Old 01-29-2009, 06:08 PM Problem with special characters...
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
Say
I have a javascript var like "Sometext/'s"...
How do I use this variable for the initial value of a form textbox?
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-29-2009, 06:24 PM Re: Problem with special characters...
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Code:
window.onload=function(){
	formelement.value = (formelement.value=='') ? defaultvalue : formelement.value;
}
Like that?
Or does it have to be immediately there when that specific elemnent loads?
If so, I don't think that's possible.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 01-29-2009, 06:30 PM Re: Problem with special characters...
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
I don't think you understand the problem, if my var is "Sometext\'s" ...
alert(var) will display in alert box as Sometext's
However textbox value...
value = var will display Sometext\'s
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 01-29-2009, 06:34 PM Re: Problem with special characters...
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
If you know which type of quotes encapsulate your whole string, just unescape all the other quotes.

If your string is encapsulated by double-quotes:
Code:
var = var.replace(/\\'/g,'\'');
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 01-29-2009, 07:15 PM Re: Problem with special characters...
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
Quotes are not the problem the \' is.
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 01-29-2009, 07:29 PM Re: Problem with special characters...
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Yea what I posted should replace \' with '.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 01-29-2009, 08:47 PM Re: Problem with special characters...
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Or, when you assign the value, you could skip the backslash altogether and just wrap the string in quotes that are opposite of what you're using within:
Code:
var value = "Sometext's";
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Problem with special characters...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24566 seconds with 12 queries