Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Swapna Agde

Greenhorn
+ Follow
since Mar 29, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Swapna Agde

Not clear with the last part i.e "for="blahId""?
Hi,
I want to set focus to a label field in HTML using javascript.

On buttonclick I am setting the focus to the label:

However, the focus is not set to the 'label'. Instead it remains on the button.
Please help.
Thanks for the reply. I got the problem.
I modified the code as follows:

Now I am able to set a focus to the element in the cell.
Thanks once again.
Sorry for the inconvience caused. I am new to posting help on forums. So kinda got messed up.
Anyway, I am able to focus the cell.
I want to set a focus to the element in the cell i.e button in this case, so that when user hits enter key in particular cell then the desired action is performed.
// for selecting the first cell, I have written following code:




//here curr.focus doesn't work. If I say tabMatrix[0][0].focus then the focus is set to the cell but not the element in the cell.

Hi,
I want to traverse the html table using arrow keys(left,right,up,down). Using arrow keys I am able to traverse.
However I am not able to set a focus to the alement inside the cell.
Following is the code:

<table class="tableExample" id="tableExample1" style="color: #6898c8" >
<tbody>
<tr id="i1_0" >
<td style="color: "><input type="button" value="test" id="testButton"></td>
<td>0-2</td>
<td>0-3</td>
<td>0-4</td>
</tr>
<tr id="i1_1">
<td>1-1</td>
<td>1-2</td>
<td>1-3</td>
<td>1-4</td>
</tr>
</tbody>
</table>


//I am populating the table data in a 2x2 matrix and trying to set focus to the element in first cell:

for(var i=0; i<noRows; i++)
{
var row = elemTable.getElementsByTagName("tr")[i];
for(j=0; j<noCols; j++)
{
var col = row.getElementsByTagName("td")[j];
tabMatrix[i][j]= col;
}
}


// Now selecting the first cell:

tabMatrix[0][0].className = "selected";
this.selectedId = tabMatrix[0][0];
var curr = tabMatrix[0][0].firstChild.id;
alert(curr);
curr.focus();


//here curr.focus doesn't work. If I say tabMatrix[0][0].focus then the focus is set to the cell but not the element in the cell.
I want to set a focus to the element in the cell i.e button in this case, so that when user hits enter key in particular cell then the desired action is performed.
Please help me how to do this?
Hi,
I want to traverse each cell of the table using arrow keys(left, right, up, down). I am able to move the highlighter to each cell as I press the arrow keys.
However I am not able to transfer the focus to each cell. Only the highlighter is moved, but focus remains on the same position where it was initially on page load.
Here is the code snippet:


On page load I am populating the table data in a 2X2 matrix and setting focus to first cell of the table.

However this ".focus" is not working here. Please can anybody tell how to transfer the focus?>