如何实现js同一页面的值的传递,希望热心大佬帮助一下我,菜鸟实习生,没有c币。。。。。。。。

我现在在做一个退伍军人就业信息管理的模块,现在我要和另一模块退伍军人基本信息连接到一起,基本信息里面没有这个用户我就无法添加就业信息,现在我要做的是点击就业信息模块主界面点击添加信息按钮,跳转到如下界面图片说明

我需要在搜索框输入用户名搜索姓名查询基本信息表内有无该用户,有该用户则会显示在下方,如图图片说明
现在我所想要问的就是,我点击这一条用户信息的确定按钮,要在下方显示的就业信息添加表单里面显示所选的这条基本信息的用户名,如图图片说明
我的问题就是不知道怎么传,上面的查询显示信息我是调用的基本信息的那个主页面查询所有的方法

/**
     * 用户基本信息查询
     */
    public String infoList() throws Exception {
        try {
            if (pageSize == null) {
                pageSize = 10;
            }
            PageUtil pageUtil = new PageUtil(request);
            pageUtil.setPageSize(pageSize);
            // 获取分页的参数
            totalCount = informationService.getTotalCount();
            // 获取分页的参数
            pageUtil.setRsCount(totalCount);
            pageSize = pageUtil.getPageSize();
            int pageCount = pageUtil.getPageCount();
            int currentPage = pageUtil.getCurrentPage();
            // 产生分页的工具条
            pageTool = pageUtil.createPageTool(PageUtil.Text);
            //从基础信息读取所有基础信息
            infoList = informationService.getAll(currentPage, pageSize,name);
            System.out.println(infoList+"##############################################################");
        } catch (RuntimeException e) {
            e.printStackTrace();
        }

        return "infoList";

    }

然后项目用的是ssh框架,公司技术比较老,大佬莫笑,页面请求跳转


@ParentPackage(value = "struts-default")
@Namespace(value = "/")
@Action(value = "employAction", results = {

@Result(name = "list", location = "/admin/system/employ/employ_list.jsp"),
@Result(name = "add", location = "/admin/system/employ/employ_add.jsp"),
@Result(name = "edit", location = "/admin/system/employ/employ_edit.jsp"),
@Result(name = "infoList",location = "/admin/system/employ/employ_add.jsp"),    

})

然后是action的全部,写的比较乱

package com.gyes.employ.action;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.jfree.data.DataUtilities;
import org.springframework.beans.factory.annotation.Autowired;

import com.gyes.currency.util.BaseAction;
import com.gyes.currency.util.DateUtil;
import com.gyes.currency.util.GsonUtil;
import com.gyes.currency.util.JsonUtil;
import com.gyes.currency.util.MessageBean;
import com.gyes.currency.util.PageUtil;
import com.gyes.employ.bean.Employ;
import com.gyes.employ.service.EmployService;
import com.gyes.system.dept.bean.Dept;
import com.gyes.system.dept.service.DeptService;
import com.gyes.system.dictionary.bean.Dict;
import com.gyes.system.dictionary.serivce.DictService;
import com.gyes.system.information.action.InformationAction;
import com.gyes.system.information.bean.Information;
import com.gyes.system.information.service.InformationService;
import com.gyes.system.information.service.impl.InformationServiceImpl;
import com.gyes.system.user.bean.User;

/**
 * 部门action
 * 
 * @author Administrator
 * 
 */

@ParentPackage(value = "struts-default")
@Namespace(value = "/")
@Action(value = "employAction", results = {

@Result(name = "list", location = "/admin/system/employ/employ_list.jsp"),
@Result(name = "add", location = "/admin/system/employ/employ_add.jsp"),
@Result(name = "edit", location = "/admin/system/employ/employ_edit.jsp"),
@Result(name = "infoList",location = "/admin/system/employ/employ_add.jsp"),    

})

public class EmployAction extends BaseAction{
    @Autowired
    private EmployService employService;
    @Autowired
    private DictService dictService;
    @Autowired
    private InformationService informationService;

    private Employ employ;
    private String[] ids;
    private List<Employ> list;
    private String name;
    private Information information;
    //基础信息集合
    private List<Information> infoList;

    private Map<String, Object> map = new HashMap<String, Object>();

    // 显示数
    private Integer pageSize;
    private Integer totalCount;
    private String pageTool;

    private Integer employId;
    // 字典中的性别集合
    private List<Dict> employwayList;
    private String informationId;

    @Override
    public String execute() throws Exception {
        return null;
    }

    /**
     * 分页查询所有用户(list)
     * 
     * @return
     * @throws Exception
     */
    public String list() throws Exception {
        try {
            if (pageSize == null) {
                pageSize = 10;
            }
            PageUtil pageUtil = new PageUtil(request);
            pageUtil.setPageSize(pageSize);
            // 获取分页的参数
            totalCount = employService.getTotalCount();
            // 获取分页的参数
            pageUtil.setRsCount(totalCount);
            pageSize = pageUtil.getPageSize();
            int pageCount = pageUtil.getPageCount();
            int currentPage = pageUtil.getCurrentPage();
            // 产生分页的工具条
            pageTool = pageUtil.createPageTool(PageUtil.Text);
            list = employService.getAll(currentPage, pageSize,name);
        } catch (RuntimeException e) {
            e.printStackTrace();
        }

        return "list";

    }



    /**
     * 增加就业信息
     */
    public String add() throws Exception {
        employ = employService.getEmploy(employ);
        //从数据字典读取就业方式
        employwayList=dictService.getDictList("dic_employway");
        return "add";
    }



    /**
     * 用户基本信息查询
     */
    public String infoList() throws Exception {
        try {
            if (pageSize == null) {
                pageSize = 10;
            }
            PageUtil pageUtil = new PageUtil(request);
            pageUtil.setPageSize(pageSize);
            // 获取分页的参数
            totalCount = informationService.getTotalCount();
            // 获取分页的参数
            pageUtil.setRsCount(totalCount);
            pageSize = pageUtil.getPageSize();
            int pageCount = pageUtil.getPageCount();
            int currentPage = pageUtil.getCurrentPage();
            // 产生分页的工具条
            pageTool = pageUtil.createPageTool(PageUtil.Text);
            //从基础信息读取所有基础信息
            infoList = informationService.getAll(currentPage, pageSize,name);
            System.out.println(infoList+"##############################################################");
        } catch (RuntimeException e) {
            e.printStackTrace();
        }

        return "infoList";

    }


    /**
     * 同一页面传递用户基本信息的姓名
     */
    public String getInformationName() throws Exception{
        Information list=informationService.getById(informationId);
        System.out.println(list+"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
        return list.getInformationname();


    }

     /**
     * 保存新增内容
     * 
     * @return
     * @throws Exception
     */
    public String save() throws Exception {
        try {
            employ.setCrateTime(DateUtil.getSysDateStr());
            Dict dic = new Dict();
            dic.setDictId(employ.getEmployway_id());
            Dict dict = dictService.getById(dic);
            employ.setEmployway_id(dict.getDictId());
            employ.setEmployWay(dict.getValue());
            employService.insertEmploy(employ);
            map.put("success", true);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", false);
            map.put("message", e.getMessage());
        }

        GsonUtil.writeToResponse(map, false);
        return NONE;

    }





    /**
     * 进入修改
     * 
     * @return
     */

    public String update() throws Exception {
        employ = employService.getById(employ.getEmployId());
        //从数据字典读取就业方式
        employwayList=dictService.getDictList("dic_employway");


        return "edit";

    }




    /**
     * 保存修改后数据
     * 
     * @return
     */
    public String saveEditEmploy() throws Exception {
        try {
            employ.setModifyTime(DateUtil.getSysDateStr());
            Dict dic = new Dict();
            dic.setDictId(employ.getEmployway_id());
            Dict dict = dictService.getById(dic);
            employ.setEmployway_id(dic.getDictId());
            employ.setEmployWay(dict.getValue());
            employService.updateEmploy(employ);
            map.put("success", true);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", false);
            map.put("message", e.getMessage());
        }
        GsonUtil.writeToResponse(map, false);
        return NONE;
    }



    /**
     * 判断用户名是否存在
     * 
     * @return
     */
    public String AjaxName() throws Exception {

        MessageBean messageBean = new MessageBean();
        messageBean.setFlag(false);
        List<Information> data = informationService.getInformationList(employ.getEmployName());
        if (data.size() > 0) {
            messageBean.setFlag(true);
        }
        PrintWriter out = response.getWriter();
        out.print(JsonUtil.objectToJson(messageBean));

        return NONE;
    }


    /*
     * 删除部门
     */
    public String delete() throws Exception {
        try {
            employService.deleAbso(ids);
            map.put("success", true);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", false);
            map.put("message", e.getMessage());
        }

        GsonUtil.writeToResponse(map, false);
        return NONE;
    }




public Integer getEmployId() {
        return employId;
    }

    public void setEmployId(Integer employId) {
        this.employId = employId;
    }

    public EmployService getEmployService() {
        return employService;
    }


    public void setEmployService(EmployService employService) {
        this.employService = employService;
    }


    public DictService getDictService() {
        return dictService;
    }

    public void setDictService(DictService dictService) {
        this.dictService = dictService;
    }

    public Employ getEmploy() {
        return employ;
    }


    public void setEmploy(Employ employ) {
        this.employ = employ;
    }


    public List<Employ> getList() {
        return list;
    }


    public void setList(List<Employ> list) {
        this.list = list;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public String getPageTool() {
        return pageTool;
    }

    public void setPageTool(String pageTool) {
        this.pageTool = pageTool;
    }

    public String[] getIds() {
        return ids;
    }

    public void setIds(String[] ids) {
        this.ids = ids;
    }

    public List<Dict> getEmploywayList() {
        return employwayList;
    }

    public void setEmploywayList(List<Dict> employwayList) {
        this.employwayList = employwayList;
    }

    public List<Information> getInfoList() {
        return infoList;
    }

    public void setInfoList(List<Information> infoList) {
        this.infoList = infoList;
    }

    public InformationService getInformationService() {
        return informationService;
    }

    public void setInformationService(InformationService informationService) {
        this.informationService = informationService;
    }

    public Information getInformation() {
        return information;
    }

    public void setInformation(Information information) {
        this.information = information;
    }







}

最后是添加页面的代码

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/struts-tags" prefix="s"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>菜单增加</title>
<link href="${pageContext.request.contextPath}/admin/css/box_css.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/admin/css/content_css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/script/jquery.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/common.css" type="text/css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/script/common.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/js/ui.js"></script>
<link href="${pageContext.request.contextPath}/admin/css/style.css" rel="stylesheet" />
<script language="javascript">
function checkEmployName(){


    var formData = jQuery("#form1").serializeArray();
    var saveURL = "<%=path%>/employAction!AjaxName?date="+new Date()+"";
    jQuery.post(saveURL,formData,function(jsonData){
        var message = jsonData.message;
        var flag = jsonData.flag;
          if (flag == true){
              document.getElementById('employName').value='';
              mizhu.alert('', '用户名已经存在,请重新填写!','');
          }

    },"json");

}





  function save(){
    var employName=document.getElementById("employName");
    if(employName.value==''){
            mizhu.alert('', '用户名称不能为空',''); 
        return false;
    }   
    var employIndustry=document.getElementById("employIndustry");
    if(employIndustry.value==''){
            mizhu.alert('', '从事行业不能为空',''); 
        return false;
    }   
    var employ_workTime=document.getElementById("employ_workTime");
    if(employ_workTime.value==''){
            mizhu.alert('', '工作年限不能为空',''); 
        return false;
    }else if(employ_workTime.value>=100){
            mizhu.alert('', '工作年限请输入小于100的数字!!!!','');  
        return false;
    }   
    var employWay=document.getElementById("employWay");
    if(employWay.value==''){
            mizhu.alert('', '就业方式必须选择!!!','');    
        return false;
    }   
    var eduName=document.getElementById("eduName");
    if(eduName.value==''){
            mizhu.alert('', '教育机构名称不能为空','');   
        return false;
    }   
    var companyName=document.getElementById("companyName");
    if(companyName.value==''){
            mizhu.alert('', '公司名称不能为空',''); 
        return false;
    }       
            var formData = jQuery("#form1").serializeArray();
            var saveURL = "<%=path%>/employAction!save";

            $.ajax({
                    type:"POST",
                    url:saveURL,
                    data:formData,  
                    dataType:"JSON",
                    success:function(obj){
                    //alert(obj.success);
                        if(obj.success){
                            $.message("success","新增用户信息成功....");
                            setTimeout(function(){
                                location.href="${pageContext.request.contextPath}/employAction!list";

                            }, 1000);
                        }else{
                            $.message("error",obj.message);
                        }
                    }
                    }); 
                //不提交表单
                return false;

                    }










        function findOut(){
        var name=$("#inputname").val();
        var saveURL = "${pageContext.request.contextPath}/employAction!infoList?name="+name+"";
        if (saveURL!="/employAction!infoList?name=") {
            window.location.href = saveURL; 

            var ifo=document.getElementById("info");
            ifo.style.display="block";
            alert(informationname);


        }else{

        }

        return false;
}; 





        function yes(){
              var emp=document.getElementById("emp");
              emp.style.display="block";
              return false;

}




    </script>
</head>




<body>


<div class="main">
<div class="increase_box">
<div class="increase_list">
<h3><b>就业信息管理</b><span></span></h3>


<div class="increase_main">
<form id="form1"  novalidate="novalidate">
<input type="hidden" id="employId" name="employ.employId" value='<s:property value="employ.employId"/>' />
<input type="hidden" id="informationId" name="information.informationId" value='<s:property value="information.informationId"/>' />
<tr>  <td align="left" valin="middle">






<form action="${pageContext.request.contextPath}/employAction!infoList" method="post">
 <td align="left" valign="middle" style="text-align:right; width:190px;"></td>
            <input type="text" class="input_k2" placeholder="请输入用户名" value="" id="inputname" />
           </td>
  <td align="left" valign="middle" style="text-align:right; width:80px;">
          <a class="byget" href="javascript:" onclick="findOut()">查询</a></td>
      </form>       


</tr>

<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="box_news_show assessment_show" style="display: block" id="info">

 <tr>
        <th width="10%" align="center" valign="middle" class="borderright">ID</th> 
        <th width="10%" align="center" valign="middle" class="borderright">姓名</th>
        <th width="10%" align="center" valign="middle" class="borderright">入伍时间</th>
        <th width="10%" align="center" valign="middle" class="borderright">退伍时间</th>
        <th width="10%" align="center" valign="middle" class="borderright">入党时间</th>
        <th width="20%" align="center" valign="middle" class="borderright">所在单位</th>
        <th width="10%" align="center" valign="middle" class="borderright">状态</th>
        <th width="20%" align="center" valign="middle" class="borderright">身份证号码</th>
        <th align="center" valign="middle" class="borderright">录入人员</th>
        <th width="5%" align="center" valign="middle">操作</th>
      </tr>
<s:iterator value="infoList" status="st">
<tr onMouseOut="this.style.backgroundColor='#ffffff'" onMouseOver="this.style.backgroundColor='#edf5ff'">
<td align="center" valign="middle" class="borderright borderbottom"><s:property value="informationId"/></td>
        <td align="center" valign="middle" class="borderright borderbottom" ><s:property value="informationname"/></td>
        <td align="center" valign="middle" class="borderright borderbottom"><s:property value="enlistmenttime"/></td>
        <td align="center" valign="middle" class="borderright borderbottom"><s:property value="retiredtime"/></td>
        <td align="center" valign="middle" class="borderright borderbottom"><s:property value="partytime"/></td>
        <td align="center" valign="middle" class="borderright borderbottom"><s:property value="unit"/></td>
        <td align="center" valign="middle" class="borderright borderbottom"><s:property value="stats"/></td>
         <td align="center" valign="middle" class="borderright borderbottom"><s:property value="numbers"/></td>
          <td align="center" valign="middle" class="borderright borderbottom"><s:property value="entrypersonnel"/></td>
          <td><input type="submit" value="确定" class="button_1" onclick="yes()"/></td>
        </tr>
</s:iterator>

        </table>




        <table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="box_news_show assessment_show" style="display: none" id="emp">
          <tr>
             <td width="20%" class="box_news_show_h3">用户名称: </td>
        <td width="28%" class="box_news_show_h1">
        <input name="information.informaationname" type="text" class="input_k2"  onblur="checkEmployName()" maxlength="20" id="infoname"/> 
            <span style="color:red;" id="infoname">*</span>
        </td>        
            <td width="20%" class="box_news_show_h3">从事行业</td>
            <td width="28%" class="box_news_show_h1">
                <s:textfield name="employ.employIndustry"  id="employIndustry"   class="input_k2" />
                <span style="color:red;" id="employIndustry">*</span> 
             </td>
          </tr>




          <tr>
            <td width="20%" class="box_news_show_h3">工作年限</td>
            <td width="28%" class="box_news_show_h1">
                <s:textfield  name="employ.workTime" class="input_k2" id="employ_workTime"  onkeyup="this.value=this.value.replace(/\D/g,'')"/>&nbsp;年
                <span style="color:red;" id="employ_workTime">*</span> 
            </td>
            <%-- <td width="20%" class="box_news_show_h3">就业方式</td>
            <td width="28%" class="box_news_show_h1">
                <s:select name="employ.employway_id" list="employwayList"  listKey="dictId" listValue="value"  id="employWay" headerKey="" headerValue="请选择" class="input_k2"></s:select>
                <span style="color:red;" id="employ_employWay">*</span> 
             </td>  --%> 
          </tr>





          <tr >
            <td width="20%" class="box_news_show_h3">培训机构名称</td>
            <td width="28%" class="box_news_show_h1">
                <s:textfield   name="employ.eduName" class="input_k2" id="eduName"  />

                <span style="color:red;" id="employ_eduName">*</span> 
            </td>
            <td width="20%" class="box_news_show_h3">公司名称</td>
            <td width="28%" class="box_news_show_h1">
                <s:textfield  name="employ.companyName" id="companyName"  class="input_k2" />
                <span style="color:red;" id="employ_companyName">*</span> 
            </td>
         </tr>



         </table>


</div>
</div>

<div class="increase_bottom"><p>
<input type="button" value="保存" class="button_1" onclick="save()"/>
                <input type="button" class="button_2" value="返回"
                            onclick="history.go(-1)"/>



</p>
</div>
<div class="clear"></div>

</div>
</form>
</body>
</html>

求求各位大佬了,救救孩子吧............................

2个回答

var一个全局变量 就可以调用了

PlumMyLover
PlumMyLover 请问具体怎么弄
5 个月之前 回复

没有看懂你的需求点呢 你能再描述一下吗? 是不是你想的 是点击确定 下面的输入框回显 这条数据的详细数据吗?

pengcan52021
pengcan52021 你为什么要写两个 table ? 如果查询有多条数据怎么办?
5 个月之前 回复
PlumMyLover
PlumMyLover 大佬,求帮助
5 个月之前 回复
PlumMyLover
PlumMyLover 是点击确定之后,回显我通过搜索后得到的那条数据的姓名,就是图二那个,我要把那个曾凡奇给回显到下面的输入框,因为我这个是为了确定基本信息表也就是用户表里面有没有这个人,如果有的话搜索出来了就点击确定回显那条信息的姓名从而进行就业信息的添加
5 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!

相似问题

8
大佬们,好多东西不太懂,希望各位大佬能指点一二
3
安卓 关于将查询的rawQuery()数据传递到数组 通过Bundle传递到另一个页面的问题
1
急求一个java能够实现杨辉三角的代码,萌新求大佬帮助。
1
点击A页面按钮打开B页面,B页面数据是查询数据库得到的,点击B页面的按钮,怎么将B页面数据回填到A页面表格?
1
【matlab求助】间接定义的符号变量的值的问题
3
关于JS中 递归的一些疑惑,希望JS大佬帮忙讲解下
0
拜托各位大佬推荐一下肌电信号采集的产品
2
C#winformDataGridView功能的实现:
1
Android页面实现的一个问题
1
java语言如何实现输入一个指令后生成一个类?
0
求AOE网的关键路径,希望有大佬帮忙解答
1
JQuery mobile实现滑动一页面里多页面切换,头部不变
2
想做个类似唱吧之类的小程序,不知道如何实现?来咨询下大佬
4
萌新提问,在Layui弹出层里如何实现可以执行图片上传的表单,请大佬们赐教
1
熟悉操作系统开发的大佬帮忙解答一下问题吧
0
unity用高通sdk发布的ar摄像头可以调用ar眼镜的摄像头驱动嘛?有没有大佬解答一下
1
如何将图片和文字上传到云数据库同一条记录中?
2
前端导航栏里首先访问A页面,然后访问B页面,再访问A页面的时候不调用接口,走缓存,这个如何实现呢?
2
ant design pro的登录界面中的登录过程实在不太懂,希望大佬们能给讲解讲解。
0
有没有大佬参照Codemirror实现过代码编辑器?