Hello Everybody I have a dynamic check box input box and I want to compute the value of the input box, in every checked box Here is my HTML code
a=(-1)
Do until objRSDefect1.eof or a = RecFound
a = a + 1
%>
<tr>
<td>
<input type=checkbox name=chkDefect value=<%=objRSDefect1("iDefectId")%>> <%=objRSDefect1("vcDefect")%>
</td>
<td><input type=text name = "<%="txtNoofDefects" & a%>" onBlur=ReviewDefects()>
</td>
</tr>
<%objRSDefect1.Movenext
Loop
and here is my javascript which is incomplete coz i Dont what to do next
function ReviewDefects()
{
for (i=0; i < elements['txtNoOfDefects'].length; i++)
}
Thanks in advance!
15 5630
Hello everybody,
I need to compute to get sum of the inputted value using Javascript(please see below), please check what is wrong on my code, when i write into alert the message is undefine2, undefine23 --number 2 and 3 is the value inputted on text box, please see also my html code
function ReviewDefects()
{
with(document.form)
{
var intDefects;
for (i=0; i < txtReject.value - 1; i++)
intDefects += (elements['txtNoofDefects' + i].value);
alert(intDefects)
if (TotalDef != txtReject.value)
hidAction.value='Defects'
submit()
HTML CODE:
<%
a=(-1)
Do until objRSDefect1.eof or a = RecFound
a = a + 1
%>
<tr>
<td ><%=objRSDefect1("vcDefect")%>
</td>
<td ><input type=text name = "<%="txtNoofDefects" & a%>" value="<%=Request("txtNoofDefects" & a)%>"onChange=ReviewDefects()>
</tr>
<%objRSDefect1.Movenext
Loop
THanks
I'm not sure if understood the question.
In order to fill values in textboxes you can set
document.getElementsByName(i + "a").value with the desired value.
For more help, please provide more details.
Use :
intDefects += document.getElementsByName('txtNoofDefects' + i).value;
Use :
intDefects += document.getElementsByName('txtNoofDefects' + i).value;
I got this error
getElementsByName is undefined
THanks
Yes, you are right, I forgot the index:
intDefects += document.getElementsByName('txtNoofDefects' + i)[0].value
Or, you can use getElementById("idvalue").value, in that case you should set the id attribute of the input text control.
Hello i got the same error, when i tried the first one, i got this message underfined2, then entered another number on 2nd input box then it return undefined23 and so no on...
while the secod one, the error is undefined222, 2 is the number inputted, when i tried to input the second number, undefined222 error
Yes, you are right, I forgot the index:
intDefects += document.getElementsByName('txtNoofDefects' + i)[0].value
Or, you can use getElementById("idvalue").value, in that case you should set the id attribute of the input text control.
Thanks, I got It, I need to convert it to integer......Your help is highly appreciated...
Yes, you are right, I forgot the index:
intDefects += document.getElementsByName('txtNoofDefects' + i)[0].value
Or, you can use getElementById("idvalue").value, in that case you should set the id attribute of the input text control.
You can convert to int using the javascript function:
parseInt(intDefects)
Yes I used parseInt...How can I set the focus to next input box after I've entered the 1st number, just like this
for (i=0; i < 26; i++)
{
if (document.getElementById("txtNoofDefects" + i ).value != '' )
intDefects += parseFloat(document.getElementById("txtNoofDefects " + i ).value);
}
txtTotal.value = intDefects
document.getElementById("txtNoofDefects" + i ).focus()
I got an error on this "document.getElementById("") is null or not an object, please help...Thanks
You can convert to int using the javascript function:
parseInt(intDefects)
Please make sure that the input text haing id = ("txtNoofDefects" + i) exists.
It seems that at the end of the for loop i = 26.
Do you have that input text haing id = "txtNoofDefects26" ?
Please make sure that the input text haing id = ("txtNoofDefects" + i) exists.
It seems that at the end of the for loop i = 26.
Do you have that input text haing id = "txtNoofDefects26" ?
That should be 25.
Yes, the last "for" iteration is executed on i = 25, then i becomes 26 and gets out.
Try this test:
[HTML]
<html>
<head>
<script language="JavaScript">
window.onload = function(){
for (i=0;i<26;i++){
window.status = i
}
alert(i);
}
</script>
</head>
<body>
</body>
</html>
[/HTML]
Or, am I missing something?
Yes, the last "for" iteration is executed on i = 25, then i becomes 26 and gets out.
Yes, you're right. Looking at the code, yes, the focus is being given to an element with id "txtNoofDefects26" which probably doesn't exist.
How can I set the focus to next input box after I've entered the 1st number
Depends how you want to do that. Is it after a maximum number of characters are pressed, then you can use this example. Alternatively, you can pass (in this function), an index which you can use instead of i.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Randell D. |
last post by:
HELP!
I am determined to stick with this... I'm getting there... for those who
haven't read my earlier posts, I'm createing what should be a simple
function that I can call to check that...
|
by: cwwilly |
last post by:
Hello,
Thanks for taking a look at this!
Problem:
I'm trying to pass multiple dynamic values between a slaveform and a
masterform. The problem I'm having is on the slaveform I loop through...
|
by: ayende |
last post by:
I've a very strange issue here. I've this JS code:
var hidden = document.createElement('input')
//hidden.type='hidden';
hidden.value = getIdForUser(userTag)...
|
by: bryan.a.fowler |
last post by:
I'm really new working with VB.net and I'm working on a simple program
with a date input. I've got a couple of questions;
1) I'm using a DateTimePicker to show both the user inputted date as...
|
by: assgar |
last post by:
Hi
Developemnt on win2003 server. Final server will be linux
Apache,Mysql and PHP is being used.
I use 2 scripts(form and process).
The form displays multiple dynamic rows with chechboxs,...
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these...
|
by: joestevens232 |
last post by:
I need help with my program. Im trying to take input from a file and store the input into different arrays in my structure. The first pary where I get the students name worked fine but now when i try...
|
by: Ben Brown |
last post by:
I'm having some problems.. I have some javascript generated input
elements with dynamic names and values.
ex:
<input name = "t1Name" .../>
<input name = "t2Name" .../>
.....
<input name =...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
| |