/    Sign up×
Community /Pin to ProfileBookmark

getting values in the row with the checked checkbox

Hi java Noobie,

I am a new comer. I have the similar problem like surendra’s.
surendra wants to delete the row. But I want to send all the values in the row to the next page(where the checkbox checked).

thanks

san

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KorSep 16.2004 — eerr... I don't know which is the problem you are talking about... You could insert a link to that thread...

I don't quite understand what values you are talking about and which is the next page...

Anyway, to not let you without some lines...

See below to try to get the text values from each rows cells. Is it of any help?
[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<head>
<script language="JavaScript" type="text/JavaScript">
function getVal(r){
t = document.getElementById('tab').rows;
al='the text values in the clicked row are:';
var celval= new Array()
for(var i=0;i<t.length;i++){
for(var j=0;j<t[i].cells.length;j++){
if(r==t[i]){
celval[j]=t[i].cells[j].innerHTML;
al=al+' | '+celval[j];
}
}
}
alert(al)
}
</script>
</head>
<body>
clik on a row to see the text values of the nested cells:<br>
<table id="tab" width="500" border="1">
<tr onclick="getVal(this)">
<td>bla1</td>
<td>foo1</td>
</tr>
<tr onclick="getVal(this)">
<td>bla2</td>
<td>foo2</td>
</tr>
<tr onclick="getVal(this)">
<td>bla3</td>
<td>foo3</td>
</tr>
</table>

</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@sanindhyaaauthorSep 16.2004 — thanks for the reply kor,

I have a html table in that i have a form which contain a table.

table contains 5 rows,3 columns. In each row the table having 2 text fields and one checkbox.

For example i checked three combo boxes then the value of the text boxes in the same row should be retrieved and displayed in the next html or jsp page(there i can manipulate with it).

Any how ur previous reply was very helpful. If u help me in this regard it will be very appreciatable.

thanks

san
Copy linkTweet thisAlerts:
@javaNoobieSep 17.2004 — The thread refered to is [url=http://www.webdeveloper.com/forum/showthread.php?s=&threadid=44390]this[/url]. Sorry i did not see your thread till today.

Logic for this is to disable those checkboxes that are not checked and their corresponding textboxes so that they will not be take into account when the form is submitted. Given your scenario..
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Example&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
&lt;script type="text/javascript"&gt;
function getValues(f){
for(var i=0; i&lt;f.chk.length;i++){
if(!f.chk[i].checked){ //if not checked disable the row's input elements
f.chk[i].disabled = true;
f.elements['txt1_'+i].disabled = true;
f.elements['txt2_'+i].disabled = true;
}else{ //if checked, append the textboxes value to the checkbox's value. Delim is '|'
f.chk[i].value = f.elements['txt1_'+i].value + '|' + f.elements['txt2_'+i].value;
}
}//end for
}//end function
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form name="frm" onsubmit="getValues(this)" action="[color=red]&lt;script here&gt;[/color]" method="get"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="chk"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt1_0"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt2_0"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="chk"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt1_1"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt2_1"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="chk"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt1_2"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt2_2"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="chk"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt1_3"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt2_3"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="chk"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt1_4"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" id="txt2_4"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;button type="submit"&gt;Submit&lt;/button&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
In this example i submitted to another page where i had a js function to decode the querystring which contains the info required.function decodeString() {
valNum = new Array();
valData = new Array();
var string, orderData;

<i> </i>string = '' + unescape(location.search);
<i> </i>string = string.substring(1,string.length);
<i> </i>valNum = string.split('&amp;');

<i> </i>for(var i=0;i&lt;valNum.length;i++){
<i> </i> valData[i] = valNum[i].split('=')[1];
<i> </i>}
<i> </i>alert(valData.join('n'));

<i> </i>var toWrite = ''
<i> </i>for(var j=0;j&lt;valData.length;j++){
<i> </i> toWrite += valData[j].split('|')[0] + ' ';
<i> </i> toWrite += valData[j].split('|')[1];
<i> </i> toWrite += '&lt;br&gt;'
<i> </i>}
<i> </i>document.write(toWrite);
}
Hope this helps.
Copy linkTweet thisAlerts:
@KorSep 17.2004 — eeer, yes, I was confused by the obsolate "row" meaning in

But I want to send all the values in the row
[/quote]
Copy linkTweet thisAlerts:
@sanindhyaaauthorSep 21.2004 — Hi java nobbie,

Thank you for your reply any how i just now saw your reply which gave a good idea for me. Once again thanks for your logic.

yours

san
×

Success!

Help @sanindhyaa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...