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.
I'm using an ActiveX control in my html page.. Each time i load the page ie pops a message box to allow the activex to run or not . Is there any way to handle that message box using javascript. Or is there any other way to avoid that message box because each time the page loads i have to give yes and then proceed. By default i've to give yes is there any way to handle that using javascript.
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:
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...
I wrote this function to avoid the enter key in some of my textboxes. In IE the function works as expected, in Netscape 6 or 7 it does not work. How can I make my function works in both IE and Netscape.
Im working on a project for my website where I would like to be able to change the value of a number by using js, and using getElemenById. For example:
"The taxi fare is $25" "A hamburger is $4"
In the above sentence I would like to be able to change the value of 25 & 4 by giving them an id and then using js to increase (or decrease) their value, to allow for future inflation, without having to go back and manually change every number on lots of pages (if for example in 1 years time a hamburger is worth $6 then the info above is outdated and should be changed). If i could use a variable such as "RateUSD = 1" I could increase "1" to say "1.05" and it would increase the value of all id='USD' by 5% onload rather than having to manually change it by typing.
I so far have come up with the code below, but I think the reason it does not work is because I have created a circular equation - id='USD" is the start of the equation, but it is also in the equation itself, and it is the resulting answer, so effectively I have created "A = A*B", or in this case "25 = 25*1.1"
I chose "id" as I would like to be able to have different currencies (with different id, such as 'EURO','GBP', etc) on the same pages and on multiple pages. I'll crack it eventually, I would just like to know if I'm heading in the right direction, or is there a better method that I could use? I found plenty of example for changing text with "innerHTML", but so far I haven't seen any for updating numbers onload by calculation, except for forms, etc, which are different.
The code:
<html> <head> <script type="text/javascript"> function changeCurrency(){
[Code].....
I will later put the js in an external file with a link to it "...src="support-files/currencyChange.js" (or something like that), but for now I have put it on the same page.
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'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..
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.
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: 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 have to access a website which does a stupid browser check and only accepts Netscape 4.7. The problem is that I have to access the website with Mozilla or Internet Explorer. Code:
w3schools has ' Try it Yourself ' tab when visitors can edit code for tutorial.i wanna doing this type of function and i have already done but only a problem facing.An additional code Website Analytic Code always appears in my ' Try It Yourself ' textarea field.how can i avoid this additional code?
I'm writing a very simple code. Basically, there will be an array of strings from which one is randomly chosen and written to an element on the page. Here is a simplified version of how I'm executing it:
My only concern is the "Active Content" warning that comes up in IE. The clientele (mostly older people) are probably going to be IE users and many of them might be so untrusting of computers that they'll take the warning as a legitimate concern. Is there another way to write this simple code to avoid the warning?
I want to know how to avoid inserting multiple records. Below is my case;
(1) I have a jsp page - when a timer for a particular product reaches 3 mins, i am getting that particular productid and sending the productid through ajax
(2) in the ajax script, i am getting the product id and redirecting to a jsp page
(3) in that jsp page, i am inserting a record to a table for that particular productid. Everything works fine, but many records are inserting, i just want to insert only one record.how to stop or avoid inserting multiple records.
Say that you have a table with id Testresults. Now you also would like to show diffrent parts of that table inside diffrent divs that also contain a table.
I naturally don't want to write the code for the table at multiple places of the page. Notice also that my site only contains of one site, containing many divs.
I want to know how to avoid inserting multiple records. Below is my case;
(1) I have a jsp page - when a timer for a particular product reaches 3 mins, i am getting that particular productid and sending the productid through ajax
(2) in the ajax script, i am getting the product id and redirecting to a jsp page
(3) in that jsp page, i am inserting a record to a table for that particular productid. Everything works fine, but many records are inserting, i just want to insert only one record.