Hi all,
I am retrieving some rows from DataBase using for loop in jsp and displaying it in a table format.In the output table I am also adding one more text box and checkbok with each row. In text box i have to enter some value manually and when i check its corresponding checkbox the value should get passes into another jsp.
This is a code by which i am assigning the name to textboxes and checkboxes - String[] arr_TextValues = new String[10];
-
String[] arr_ChkValues = new String[10];
-
-
arr_TextValues[i] = "Text"+i;
-
arr_ChkValues[i] = "Chk"+i;
where i = number of rows retrieved. - <td><input type=text name=<%=arr_TextValues[i]%> value=""/></td>
-
<td><input type="checkbox" name=<%=arr_ChkValues[i]%> VALUE="0" align ="center" ></td> .
Now to check and get the value of the textbox i am checking the checkbox value using javascript as :- - function check()
-
{
-
for(l=0;l< i;l++){
-
-
if(document.form1.chk0.checked ==true)
-
{
-
-
something to retrieve the value of textbox and pass it to another jsp!!!
-
-
-
}
-
}
how can i retrieve the value of the various checkboxex and pass it to another jsp?
any help regarding how to do this will be appriciated .
17 19096
Hi all,
I have to check the value of the 10 checkboxes using javascript, does anyone khow how to do this ?? i am using the code : - function check()
-
{
-
for(i=0;i< 10 ;i++){
-
-
if(document.form1.chki.checked ==true)
-
{
-
alert("hi");
-
}
-
}
-
-
}
-
but it is now taking the value of "i" in (document.form1 .chki.checked ==true).
Thanks in advance .
acoder 16,027
Recognized Expert Moderator MVP
Welcome to Bytes.
To take the i value to use for the name of the checkbox, use the elements array: - document.form1.elements["chk"+i].checked...
PS. merged threads.
Thanks for your reply !
The problem is still not solved, it is giving me some error 'document.form1 .elements[...].checked' is nill or not an object -
function check()
-
-
{
-
no_of_row = document.form1.dev.value
-
-
for(l=0;l<no_of_row;l++)
-
-
{
-
if(document.form1.elements["Chk"+l].checked ==true)
-
{
-
-
var v=document.form1.elements[l].value;
-
alert(v);
-
-
return true;
-
-
}
-
-
else
-
-
{
-
-
-
-
alert('Please check the assign token');
-
return false;
-
}
-
-
-
-
}
-
-
}
-
please suggest me what to do now .
acoder 16,027
Recognized Expert Moderator MVP
A checkbox name can be a set of checkboxes. If you want to refer to one checkbox, you may be better off using an id, e.g.
[html]<input type="checkbox" name="Chk0" id="Chk0">[/html]and then using document.getEle mentById("Chk0" ) to access it.
Thanks again!
The complication in my code is that when i fetch rows i am associating a checkbok and textbox with every row ..
now to access the data of the text box whic i enter manually i have to assign unique names to both checkbok and textbox.
please have a look into the code .
in this code i have to fetch the value of the text box if its corresponding checkbox is checked.
I will be thankful if you can help me out .
acoder 16,027
Recognized Expert Moderator MVP
Now that you've set the ID, the following should work: - for(l=0;l<no_of_row;l++) {
-
if (document.getElementById("Chk"+l).checked) {
-
var v = document.getElementById("Text"+l).value;
-
// v now contains the text box value
-
Hi a have come up with the following code :
i am now storing the name value of checkbox into a variable and passing it in -
document.form1.chk.checked ==true
but it is not taking the value of var . could you please tell me how to do this ? -
function check()
-
-
{
-
-
no_of_row = document.form1.dev.value
-
-
// alert(no_of_row);
-
-
for(l=0;l<no_of_row;l++)
-
-
{
-
-
var txt="Text"+l; alert(txt);
-
var chk="Chk"+l; alert(chk);}
-
-
if(document.form1.chk.checked ==true)
-
{
-
-
var v=document.form1.txt.value;
-
if(v!="")
-
alert(v);
-
else
-
alert("Please enter id");
-
-
return true;
-
-
}
-
-
else
-
-
{
-
-
-
-
alert('Please check the assign token');
-
return false;
-
}
-
-
-
-
}
-
-
}
thanks!
Hi all,
I have to pass the value of a variable into the following code :- -
function check()
-
-
{
-
-
no_of_row = document.form1.dev.value
-
-
// alert(no_of_row);
-
-
for(l=0;l<no_of_row;l++)
-
-
{
-
-
var txt="Text"+l;
-
var chk="Chk"+l;
-
}
-
-
if(document.form1.chk.checked ==true)
-
{
-
-
var v=document.form1.txt.value;
-
if(v!="")
-
alert(v);
-
else
-
alert("Please enter id");
-
-
return true;
-
-
}
-
-
else
-
-
{
-
-
-
-
alert('Please check the assign token');
-
return false;
-
}
-
-
-
-
}
-
-
}
-
There is an error that - document.form1.chk.checked ==true
is null or not an object.
this means it is not taking the value of the variable "chk". does anyone know how to pass the value of var into - document.form1.chk.checked ==true
Any help in this regard will be appriciated .
thanks!
hsriat 1,654
Recognized Expert Top Contributor
Can you show the HTML part, the one you get from view source?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: claudel |
last post by:
Hi
I have a newb PHP/Javascript question regarding checkbox processing
I'm not sure which area it falls into so I crossposted to comp.lang.php
and comp.lang.javascript.
I'm trying to construct a checkbox array in a survey form where one
of the choices is "No Preference" which is checked by default.
If the victim chooses other than "No...
|
by: Nath |
last post by:
Please help!?
I am new to writing html, javascript, pretty new to MySQL but quite
proficient at writing Perl and i'm a quick learner.
I am building a database driven website and i am a little stuck:
I have page of results obtained from a MySQL query presented as a table (the
first column having checkboxes for each of the rows in the table,...
|
by: Fred |
last post by:
Hi,
i know how to pass a value from Javascript to ASP with a hidden field into a
form and submitting it, or with cookies, but here i have to pass a lot of
data in an array.
There is a list of product the visitor can order by clicking one or more
checkboxes. I made a form containing input with type "checkbox" like:
<form>
<input...
|
by: jaya |
last post by:
Hi,
I am using asp.net to pass parameters from .aspx page to my Microsoft
reporting service.
My .aspx page has checkbox. If it is checked it the chekbox should pass
value =0 to my report
<INPUT id="ReviewedBy" style="WIDTH: 16px; HEIGHT: 20px"
type="checkbox" name="ReviewedBy" value = 0>
if the check box is unchecked it should pass value...
|
by: Marc Castrechini |
last post by:
I have a page that changes an <ASP:Checkbox value based on a user entered
value in a textboxm using client side Javascript.
After my submit is fired the value for the chkMyCB.checked does not get the
latest value of the checkbox.
Does this sound like a posibility and if so how can I force the server to
get the new value from the page?
...
| |
by: DotNetJunkies User |
last post by:
1.
i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis....
2. after population there should be validation in checkboxlist.....
that is if user clicks a button wihout checking any one of them(i.e. at least...
|
by: clinttoris |
last post by:
Hello Experts,
I have been told to post this in the Javascript forum as I want to do
this client side just before my form gets submitted. Once the user
clicks the submit button a javascript function needs to run and
validate all the checkboxes on my form and make sure none of them are
unchecked. I suck at Javascript and my problem is...
|
by: Chuck Anderson |
last post by:
My knowledge of JavaScript is limited. I learn from example and then
adapt those examples to suit my needs.
I have stumped myself on this one.
I have a form with checkboxes that I want to group by using a two
dimensional array.
<form name=msgs>
|
by: Muffinthief |
last post by:
Hi guys, what I'm trying to do is very simple. Just make a simple check/uncheck button for some checkboxes. Here's what I have.
<script language="JavaScript">
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field.checked = true ;
}
function uncheckAll(field)
{
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |