I'd like to bring data to the list I brought to the for Each door using both input type check box and radio button

Asked 2 years ago, Updated 2 years ago, 132 views

I'm a beginner, so I can't explain in detail I'm sorry

There is a member information and study table, but I want to bring a member information list, select a member as a check box, select the leader of the study as a radio, and put it in at once, but I don't know if it's because I brought both values with the same member name, but the data is not input properly

Please understand that it is difficult to explain in detail When I register for a study, I try to bring my membership information to the pop-up window I'd appreciate it if masters could share their wisdom

<c:forEach items="${list}" var="list">
    <tr>
        <td width="10%"><input type="checkbox" name="selectedStudent" id="selectedStudent" value="${list.studentNo},${list.studentName}"></td>
        <td width="15%">${list.studentNo}</td>
        <td width="15%">${list.grade}</td>
        <td width="24%">${list.studentName}</td>
        <td width="24%">${list.studyName}</td>
        <td width="12%"><input type="radio" name="selectedleader" id="selectedleader" value="${list.studentNo},${list.studentName}"></td>
    </tr>       
</c:forEach>

java jsp jstl

2022-09-21 11:38

3 Answers

In the script, change selectedstudent to selectedleader.


2022-09-21 11:38

With the help of a friend, it was possible to retrieve the information of the selected student by inserting an additional script below. What kind of script should I enter to retrieve the leader information?

function cntCheck() {

var select = eval("document.selectform");
var cntCheck = 0;

if (confirm("Are you sure you want this?) == true) {

    document.getElementById("selectform").action="FieldWriteController.do"
    document.getElementById("selectform").submit()
} } else {
    return;
}

for(i=0; i<select.selectedstudent.length; i++) {
    if(select.selectedstudent[i].checked == true) {
        cntCheck++;
    }
}
setCheck();

}

function setCheck() {

    var select = eval("document.selectform");
var checked = document.getElementsByName("selectedstudent");
var chkList = "";
var afterStr = "";
var no = "";
var name = "";

for(var i=0; i < select.selectedstudent.length; i++) {
    if(checked[i].checked == true) {
        chkList += checked[i].value + ",";
    }
}   

var afterStr = chkList.split(',');

for(var i =0; i < afterStr.length-1; i++) {
    if(i % 2 == 0) {
        no += afterStr[i]+","; 
    } } else {
        name += afterStr[i]+","; 
    }
}


opener.document.field.studentNo.value=no;
opener.document.field.studentName.value=name;
self.close();

}


2022-09-21 11:38

Thank you for your answer When I changed to leader, the leader information was included By the way, I want to bring two pieces of information together, so do I just have to change the name of the same script and use it? I just tried it, but both of them didn't print out

<th scope="col">Leader name</th>
    <td>
    <div class="textbox" style="white-space:nowrap;">
    &nbsp;<textarea id="studentName" name="studentName" cols="40%" rows="5%"readonly="readonly"></textarea>
            </div>
            </td>
</tr>
<tr>
    <th scope="col">Student Name</th>
    <td>
    <div class="textbox" style="white-space:nowrap;">
    &nbsp;<textarea id="studentName" name="studentName" cols="40%" rows="5%" readonly="readonly"></textarea>
    </div>
    </td>
</tr>


2022-09-21 11:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.