Eval And Non-English Characters Conflict?
Nov 7, 2006I am pulling data off a server via AJAX, and some of that data has
non-English characters in it. The data is in the form of a json: Code:
I am pulling data off a server via AJAX, and some of that data has
non-English characters in it. The data is in the form of a json: Code:
I have a problem in creating request with most jquery autocomplete plugins. I have an app that users must complete inputs with none English characters (in here Persian)
But 90% plugins not work correctly! Problem here that when typing a none-English character I have any request! But when I push general key like back space or space in between character it work and request create.
I used more and more plugins and test firebug for ensure to create request. With English character I havent problem
please i want to know if there is a possibility to force the user to type English characters coz i made all my web site in arabic and germany languages i want to force user to type the username and password in English characters
View 1 Replies View RelatedI like to detect whether the basic language of the client browser(O/S) is English or not .
The following would-be code doesn't work correctly, but it will show what I want. Code:
would-be code
<if it is English>
send to English version page
<else>
send to my mother tongue version page
</if>
I have two input box
input box 1 : name is first
input box 2 : name is second
Suppose if I enter "family" should be transliterated using google and the output in french should be displayed in the second input box. How to do this???
I am trying to make a website in different languages. Can anyone help
me, as in what steps I need to take and what extra codes I need to
write.
I have a form that has 4 fields.
First 3 fields are in lang that is RTL.
last field is for email and I want to have it work only in English.
I have used this script:Code:someString.replace(/[^A-Za-z0-9 .]/g, '')...many times to remove non-alphanumeric and non "." and " " characters but am having to re-think its use as I start working on non-American English languages for string replacement. The reason for this is that this RegExp also pulls out special characters such as "ó" and "ñ". I'm not certain, but I think it would also remove all double-byte characters such as various Asian-language words.Has anyone run into this problem and have they found a simple coding solution to catch all non-English special characters?
View 7 Replies View RelatedI'm kind of new to js, I wanted to write some non english chars inside an array, and it only seems to work if I write unicode notation, e.g. "u1234" per char. I was wondering if there is some easier way to do this, maybe somehow specify to the browser that the js file is utf8-encoded or something similar, but I'm not sure how to do that.
View 3 Replies View RelatedI have a textarea which the user can enter whatever text he chooses.
<TEXTAREA id=body name=body></TEXTAREA>
I would like to avoid supporting HTML tags in this textarea at the
moment, therefore I use the following HTML encode support:
Dim p_Body : p_Body = Server.HTMLEncode(Request.Form("Body"))
This works fine if I write text in latin characters (in English) - than
only the HTML tags are encoded.
But if I write text in other UTF-8 chars (e.g.: Hebrew) - all the text
is encoded, and it becomes unreadable.
I am having problems with the code below (obviously) coming up with illegal character for various characters within the field name
which is: S_Gift Finder1_0
I have tried various ways of escaping the characters but to no avail.
I am unable to change the name of the field as it it comes from an external off-the-shelf package. Code ....
I have character counter for textarea wich counting the characters.
Special character needs same place as two normal characters because of
16-bit encoding.
Counter is counting -2 when special character is added like some
language specific char.
How to count specials like 1 char?
given that I have a js file included which is written programatically and I
can't change it. I would like to know how to do the following using
something other than the deprecated eval().
whats in the js file
var numArrays=something;
var data0 = new Array();
data0.name="name";
data0.data="some data";
var data1 = new Array();
data1.name="another name";
data1.data="some more data";
etc ....
function getData(arrayName) {
for ( var i=0;i<numArrays:i++) {
var el=eval('data'+i);
if (arrayName = = el.name) doSomething(el.data);
}}
var fns = ['orde', 'no', 'kml', 'snf', 'td', 'ty', 'tn', ...up to 21
elms...];
var snv = new Array();
var vals = new Array();
for (i = 0; i < N; i++) {
for (j = 0; j < fns.length; j++)
vals[j] = some value;
snv[i] = new makeData(vals);
}
function makeData(vals) {
for (k = 0; k < vals.length; k++)
//the following line doesn't work
eval("this."+fns[k]+"="+vals[k]);
//neither this one
this.eval(fns[k]) = vals[k]);
}
how can i make it without writing it the long way:
this.orde = vals[0];
this.no = vals[1];
this.kml = vals[2];
and so on?
how comes the following doesnt work
fieldNotes2=eval("Message.notes["+id2+"]");
i believe it's because of the [] but i need to keep them!
I've made a funny program using eval()...it will let the person(on the page) to write javascript and have it compile(if thats the right word for it)! its quite cool, i dont know how handy it might be, but here it is none the less...
code:
<html>
<head>
<title>test</title>
<script language="JavaScript">
function submitCode(){
var the_code = window.document.form_1.textarea_1.value;
var run_the_code=eval(the_code);
}
</script>
</head>
<body>
<center>
<h1>write some code!</h1>
<form name="form_1">
<textarea name="textarea_1" rows=10 cols=40>
</textarea>
</form>
<form onSubmit="return false;">
<input type="submit" value="submit your code" onClick="submitCode();">
</form>
</center>
</body>
</html>
very simple stuff, but for those of you who are unfamilir with eval, its pretty cool, huh?
I'm having some weird problem with evaluating the continue statement.
Within a for loop I'm trying to evaluate a string (generated somewhere
earlier) which basically has the continue statement in it. IE6 seems to
have major problems with that as it generates an error "Can't have
'continue' outside of loop". Does anyone know why and/or have a
workaround? I haven't tried any other browser since this one is the
only one available (company policy).
I have included some code to reproduce this behaviour. The first and
second if statements of the testeval function behave as expected. The
third one however produces the mentionned error. Code:
I am trying to do the following but i get an error, is there no way i
can use eval to print have it assigned to a predeterminded variable.
eval (object_name + "_CalCalendar") = new CalendarPopup(object_name);
Cannot assign to function result.
Here is my code.
function CallDisplay()
{
nodeobj=new mynode();
x="displayId("+nodeobj+")";
eval(x);
}
function displayId(node)
{
alert(node.myid);
}
function mynode()
{
this.myid="aa";
}
In CallDisplay() I am getting the error as "Microsoft JScript
Compilation error ']' expected". Any one can suggest me how to
overcome this.
I'm running some javascript over a server side generated web page
and have multiple generated empty select statements, that I want to
populate when the page is loaded. As HTML doesn't do arrays each
select is individually named withe MySelecti where i is an incremental
from 1.
I know all my variables are correct (i, OptionsCount) and my arrays
of MyValues and MyDescription's exist for multiple enteries and if I
bring out an example of what I thought each line would eval too( say
document.MyForm.MySelect1.options[1]=new
Option('Value1','Description1') the line works fine, for the life of me
(i'm sure I'm missing something obvious) the eval line won't eval..
for(i = 1; i<=row; i++) {
for (j = 1; j <=OptionsCount; j++) {
eval="document.MyForm.MySelect"+i+".options["+j+"]=new
Option('"+MyValues[j]+"', '"+MyDescription[j]+"')";
eval(eval);
}
}
I am trying to assign an "onclick" event to a dynamically-created DOM
element (an image).
I have read countless times that "eval()" is to be avoided at all costs.
However, I cannot seem to get my new onclick to work without it.
Here's what I have so far:
myeval = 'detachFile(this);'
detachImage = getElementById('detach-jfhahhf');
detachImage.onclick = function() { eval(myeval) }
This works perfectly fine for me, but this is a web-app that will be
exposed to public users, and I obviously don't want them being able to
eval anything if i can help it.
Can that be done without the eval()?
i came up with the following, to help me test the syntax of functions while i'm writing them. i've only been using it for a day or two, but so far, it's been really handy.
<HTML>
<HEAD>
<TITLE>Evaluator</TITLE>
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<BODY>
<FORM>
<TABLE WIDTH="100%" HEIGHT="100%">
<TR>
<TD COLSPAN="2" HEIGHT="100%"><TEXTAREA NAME="script" STYLE="width: 100%; height: 100%"></TEXTAREA></TD>
</TR>
<TR>
<TD ALIGN="CENTER"><INPUT TYPE="BUTTON" VALUE="eval" OnClick="eval(this.form.script.value);"></TD>
<TD ALIGN="CENTER"><INPUT TYPE="RESET" VALUE="clear"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
In Visual Basic this is easy to do, but I'd like to do it in JavaScript (without writng my own).
I'd like to put a text box on a form so the user can type something like:
3+5*(sin(90))^2
and have the answer to the equation displayed.
I guess it would be possible to translate it into a javascrip command
x=Math.pow(3+5*(Math.sin(90)),2) and then execute the translated line using Eval(x);, but maybe there's an easier way. Any thoughts?
I have a script that will loop through all the INPUT elements of a form; if the input is a submit it will disable the submit (or enable the submit, depending upon what is passed to the function.) I hate using eval() - I avoid it whenever I can! Is there a better way to dynamically process the ".disabled = 'true'/'false';" portion?
[Code]..
this is the code I'm working on:
Code:
var tabs = new Control.Tabs('menu');
var pattern = 'tab=';
var nStr = location.href;
if(nStr.match(new RegExp (pattern,'gi'))){
var id = nStr.split(pattern);
[Code]...
It searches for the query string 'tabs=' and then splits the result to get the id of the tab. Then it uses this to set the active tab. If the url doesn't include the query string it set the tab to the first one.
The code works but it uses Eval to convert the id string (id[1]) to a variable and I was wondering if there was an alternative.
I am try'g to send window.location.href to the server script who will
generate dynamic javascript according to the referral name comg in as
param:
<script language="javascript" src="NO JAVASCRIPT CAN BE USED HERE" />
So I am see'g If I can use eval todo something what I am doing
I have tried almost everything, following is being last one ....