This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I using DisplayTag to display dynamic rows of data in my jsp's. My first column needs to be a selectable column (radio buttons). I am able to display a column of radio buttons by using the <input> tag. My question is: How do I auto-select the first row of data? (by default the first row must be selected)
In <input> tag of type radio button, there is an option
<input type = "radio" name = "" checked>
with the "checked" word in the tag, the initial state of the radio button will be selected.
I hope this helps.
Sumithab Baskaran
Ranch Hand
Joined: Oct 29, 2004
Posts: 52
posted
0
Yes. I tried using checked. But, by default the last row of the list is selected always. I want the first row to be selected, not the last.
Any other suggestions? Thanks
Madhuri Chanda
Greenhorn
Joined: Nov 09, 2005
Posts: 10
posted
0
I guess the code which you gave is only part of the code... how many radio buttons are there total..?
Make sure that only for the first radio button <input type = "radio" ... > it is checked... the next radio button input tags should not be checked. if all the radio buttons are checked.. obviously it checks the last radio button.
By chance, are you running into the above case?
if it is not the above case, then on body onload() function add the following statement
document.FORM_NAME.selector.checked = true;
where FORM_NAME is the name of the form given in the <FORM> tag and "selector" is the name of your input radio button field.
let me know if this helps.
Sumithab Baskaran
Ranch Hand
Joined: Oct 29, 2004
Posts: 52
posted
0
I am using displayTag. In this line, <display:table name="searchResults" /> -- the searchResults is a list that the displayTag iterates through and displays 3 columns - 1) selector column with radio buttons 2) name column 3) description column So, there can be any number rows in the list. 'searchResults' is a dynamic list that gets populated by making a call to the database in the Action class.
The code that I first posted is complete. In this situation, I want to auto-select the first row.
Thanks
Madhuri Chanda
Greenhorn
Joined: Nov 09, 2005
Posts: 10
posted
0
ok.. since it is a dynamic list.. slight modification to the previous posted hint might work like:
function fnOnLoad(){ document.FORM_NAME.selector[0].checked = true; // or something like // if(searchResults.length > 0) // document.FORM_NAME.selector[0].checked = true; }
since, for any number of radio buttons, the name of input type will be "selector"... hope the above code might work.
King Cobra
Greenhorn
Joined: Nov 22, 2005
Posts: 1
posted
0
Originally posted by Madhuri Chanda: ok.. since it is a dynamic list.. slight modification to the previous posted hint might work like:
function fnOnLoad(){ document.FORM_NAME.selector[0].checked = true; // or something like // if(searchResults.length > 0) // document.FORM_NAME.selector[0].checked = true; }
since, for any number of radio buttons, the name of input type will be "selector"... hope the above code might work.