实现鼠标单击获得table一行的分别值

本文介绍了一个包含角色创建、修改及删除功能的管理界面实现细节。通过JavaScript和HTML结合使用,实现了表格中角色信息的选择和交互操作,如背景色变化等,并针对不同操作触发相应的表单提交。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这篇文章为网络转载,作为平时笔记,红色部分是我用到的
<%--
/**
* SSZUTC Shenyi 20Jan2005 replaced previous log mode with SSCLogger
*/
--%>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portlet" %>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1" %>


<%@ page import="java.util.*" %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">


<script language="javascript">
[color=red]
var currentActiveRow;
function changeActiveRow(obj)
{
if(currentActiveRow) currentActiveRow.style.backgroundColor="";
currentActiveRow=obj;
currentActiveRow.style.backgroundColor="gray";
//var temp=currentActiveRow[0].innerText;
var roleName=currentActiveRow.cells[0].innerText;
var roleType=currentActiveRow.cells[1].innerText;
var description=currentActiveRow.cells[2].innerText;
alert(" message:"+ roleName+ " "+ roleType+" "+description);
//alert("message:"+temp);
} [/color]
function submitAction(action)
{
// alert("action clicked:"+action);
var submitForm = "";
//submitForm.submit();
if( action == 'create')
{
createReportGroupForm = window.document.forms['<portlet:encodeNamespace value=""></portlet:encodeNamespace>CreateReportGroupForm'];

// alert("action set to:"+ createReportGroupForm.action);

createReportGroupForm.reportSourceID.value = this.reportSourceID.value;
createReportGroupForm.reportSourceName.value = this.reportSourceName.value;
createReportGroupForm.applicationID.value = this.applicationID.value;
createReportGroupForm.applicationName.value = this.applicationName.value;

// alert ("app + this.applicationName.value);

createReportGroupForm.submit();
}
else if( action == 'modify')
{
modifyReportGroupForm = window.document.forms['<portlet:encodeNamespace value=""></portlet:encodeNamespace>ModifyReportGroupForm'];

if (this.AvailableReportGroups.selectedIndex == -1) {
alert ("Please select a report group ");
return;
}

// alert("action set to:"+ modifyReportGroupForm.action);

modifyReportGroupForm.reportSourceID.value = this.reportSourceID.value;
modifyReportGroupForm.reportSourceName.value = this.reportSourceName.value;
modifyReportGroupForm.applicationID.value = this.applicationID.value;
modifyReportGroupForm.applicationName.value = this.applicationName.value;

modifyReportGroupForm.reportGroupName.value = this.AvailableReportGroups.options[this.AvailableReportGroups.selectedIndex].text;
modifyReportGroupForm.reportGroupName.value = this.AvailableReportGroups.options[this.AvailableReportGroups.selectedIndex].title;
modifyReportGroupForm.reportGroupID.value = this.AvailableReportGroups.options[this.AvailableReportGroups.selectedIndex].value;

// alert ("group + modifyReportGroupForm.reportGroupName.value);
// alert ("app + this.applicationName.value);

// alert ("title = " + this.AvailableReportGroups.options[this.AvailableReportGroups.selectedIndex].title);

modifyReportGroupForm.submit();
}
else if( action == 'delete')
{
deleteReportGroupForm = window.document.forms['<portlet:encodeNamespace value=""></portlet:encodeNamespace>DeleteReportGroupForm'];

if (this.AvailableReportGroups.selectedIndex == -1) {
alert ("Please select a report group ");
return;
}

var Input;
Input = confirm("Are you sure to delete the selected report group?")
if(Input == false){
return;
}

deleteReportGroupForm.reportSourceID.value = this.reportSourceID.value;
deleteReportGroupForm.applicationID.value = this.applicationID.value;
deleteReportGroupForm.applicationName.value = this.applicationName.value;
deleteReportGroupForm.reportSourceName.value = this.reportSourceName.value;
deleteReportGroupForm.reportGroupID.value = this.AvailableReportGroups.options[this.AvailableReportGroups.selectedIndex].value;
deleteReportGroupForm.reportGroupName.value = this.AvailableReportGroups.options[this.AvailableReportGroups.selectedIndex].text;
deleteReportGroupForm.reportGroupName.value = this.AvailableReportGroups.options[this.AvailableReportGroups.selectedIndex].title;
// alert("action set to:"+ deleteReportGroupForm.action);

// alert ("app + deleteReportGroupForm.applicationID.value);
// alert ("report group + deleteReportGroupForm.reportGroupID.value);

deleteReportGroupForm.submit();
} else if ( action == 'cancel') {

cancelForm = window.document.forms['<portlet:encodeNamespace value=""></portlet:encodeNamespace>ReportGroupAppSourceForm'];

// alert("action set to:"+ cancelForm.action);

cancelForm.submit();

}
}
function validate()
{
return true;
}

function func_1(thisObj, thisEvent) {
//use 'thisObj' to refer directly to this component instead of keyword 'this'
//use 'thisEvent' to refer to the event generated instead of keyword 'event'
cl;
}</script>



<jsp:useBean scope="request" />


<%




String fromMyViewJSP = request.getParameter("fromMyViewJSP");
// if (fromMyViewJSP == null) {

%>



<title>ReportGroupAdmin</title>



<table width="100%" border="1" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td width="100%" valign="top">
<table width="95%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr>
<td >Report Groups</td>
</tr>
<tr>
<td valign="top" height="53">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="3%"><img src='<%= response.encodeURL("/images/info.gif") %>' width="18" height="15"></td>
<td valign="top" width="97%">Select
a report group from the list box before selecting an action
button (Create New Group, Modify Selected, Delete Selected).
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30"><br>
<a href=" ('cancel')"><< Report Group App Source </a> | Report
Group Admin
</td>
</tr>
</table>
</td>
</tr>

<tr>
<td height="26">
<table width="100%" RULES="none" FRAME="box" border="1" bordercolor="#eaeaea" cellspacing="0" cellpadding="2">
<tr height="18">
<td width="46%" > </td>
<td width="54%" > </td>
</tr>
<tr>
<td ></td>
<td > </td>
</tr>
</table>
<br>
<table width="100%" rules="none" frame="box" bordercolor="#eaeaea" border="1" cellspacing="0" cellpadding="0">
<tr height="18">
<td > Existing Report Groups</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr height="30">
<td width="25%" valign="middle">
<input type="button" value="Create New Role" create')" >
</td>
<td width="25%" valign="middle">
<input type="button" value="Modify Selected"
modify')" >
</td>
<td width="25%" valign="middle">
<div align="left">
<input type="button" value="Delete Selected" delete')" >
</div>
</td>

<td width="21%" valign="top">  </td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="1" cellspacing="0" cellpadding="2" height="55" bordercolor="#eaeaea">
<tr>
<td height="20" valign="top">

<TABLE width="100%" height="20" border="1">
<tr>
<th>Role Name</th>
<th>Role Type</th>
<TH>Description</TH>
</tr>
</TABLE>
</td>
</tr>
<tr>
<td height="230">
<div style="width=100%; height:230; overflow:auto">
<table width="100%">
<tr ><th>wwwa</th><th>wwwq</th><th>wwwe</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
<tr ><th>www</th><th>www</th><th>www</th></tr>
</table>
</div>


</td>
</tr>
</table>
<p> </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值