473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

run time check

Hi

I have this problem.

I have a function like this.

function evaluate(tekst)
{
var ctrl;

ctrl = "control" + 5;
if(tekst=='good')

{
document.formname.ctrl .checked = true;
}
}

In the form there is a checkbox control named control5

but this doesn't work. I have the error ctrl not found in form.
I understand the reason but which is the solution?
Thanks

Alain Dhaene
Jul 20 '05 #1
6 1590
Alain Dhaene wrote on 06 jan 2004 in comp.lang.javascript:
ctrl = "control" + 5;
if(tekst=='good')

{
document.formname.ctrl .checked = true;
}


document.formname[ctrl].checked

?

================

more consize, also unchecks:

document.formname["control"+5].checked=(tekst=='good')

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Alain Dhaene wrote on 06 jan 2004 in comp.lang.javascript:
ctrl = "control" + 5;
if(tekst=='good')

{
document.formname.ctrl .checked = true;
}


document.formname[ctrl].checked

?

================

more consize, also unchecks:

document.formname["control"+5].checked=(tekst=='good')

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Perhaps?

<html>
<head>
<title>control5.htm</title>
<script language="javascript" type="text/javascript">
<!--
function evaluate(tekst) {
var form = document.forms[0];
var ctrl;
ctrl = eval("form.control" + 5);
if (tekst=='good') {
ctrl.checked = true;
}
}
// -->
</script>
</head>
<body>
<form>
<input type="checkbox" name="control5">
<input type="button" value="check" onclick="evaluate('good')">
</form>
</body>
</html>
Jul 20 '05 #3
McKirahan wrote on 06 jan 2004 in comp.lang.javascript:
var form = document.forms[0];
var ctrl;
ctrl = eval("form.control" + 5);


eval is evil!

document.forms[0]["control"+5].checked=(tekst=='good')
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
McKirahan wrote on 06 jan 2004 in comp.lang.javascript:
var form = document.forms[0];
var ctrl;
ctrl = eval("form.control" + 5);


eval is evil!

I knew I was going to get some flak for suggesting its use.

Can you give me (or point me to) the reasons?

Thanks.
Jul 20 '05 #5
In article <7iBKb.758459$Tr4.2155828@attbi_s03>, "McKirahan"
<Ne**@McKirahan.com> writes:
eval is evil!

I knew I was going to get some flak for suggesting its use.

Can you give me (or point me to) the reasons?


http://www.jibbering.com/faq/#FAQ4_39

http://www.jibbering.com/faq/#FAQ4_40

Major Reason: Its inherently slower (I know of one instance where eval actually
performs as well/better than other methods).
--
Randy
Jul 20 '05 #6
McKirahan wrote on 06 jan 2004 in comp.lang.javascript:
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
McKirahan wrote on 06 jan 2004 in comp.lang.javascript:
> var form = document.forms[0];
> var ctrl;
> ctrl = eval("form.control" + 5);


eval is evil!

I knew I was going to get some flak for suggesting its use.

Can you give me (or point me to) the reasons?


<http://groups.google.com/groups?num=100&q=eval+evil+javascript>

<http://www.google.com/search?as_q=eval+evil+javascript&num=100>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kenneth | last post by:
Hello, I'm having some serious problems debugging a script that I'm trying to make work. I'm working on a form where a user can type in a time (in the format of HH:MM), and another script...
9
by: Joakim Braun | last post by:
Unonload doesn't get much time when quitting the browser. So how can you do time-consuming actions then? I'm doing a web-based MySQL interface. Records are presented as tables of links. The...
5
by: Erich Schreiber | last post by:
In the Python Library Reference the explanation of the time.sleep() function reads amongst others: > The actual suspension time may be less than that requested because > any caught signal will...
4
by: luscus | last post by:
I am trying to device a formula so that when i check of a yes/no box (done) it will automatically add the time in a field called "End Time" and at the same time stamp the amount of minutes...
7
by: jlara | last post by:
Having been stung by the same problem twice, I would like to automatically check if the bitfields are regarded properly by the compiler. For example, if I define the following structure: ...
4
by: John Smith | last post by:
Hi I'm porting some C++ code to new platforms and have some 1-byte aligned structures which need a specific size. Since datatypes can vary on different platforms (which I found out the hard way...
8
by: Antony | last post by:
compiler£ºVisual Studio.Net 2003 (VC7.1) compile type£ºDebug problem: wanted more information about the "Run-Time Check Failure #n",thanks! Example1: #include "stdafx.h" void malice() {...
14
by: Urs Thuermann | last post by:
What is the most elegant way to check certain conditions at compile time? I.e. I want a compile time error to be generated if for example the size of a struct is not a multiple of 4 or if one...
4
geo039
by: geo039 | last post by:
I tried to write a simple application that takes user input by text and time selected by date time picker. It displays the appt description in one list box and the time in another list box. I wrote...
11
by: Dirntknow | last post by:
Further to my recent post in this newsgroup i've got to admit i'm struggling. I've no experience with javascript or it's workings. What i'd like is a simple converter to allow a user to input the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.