提交后在同一页面的表中显示html表单值

时间:2018-03-26 14:04:23

标签: jquery html mysql

我收到错误当我点击保存按钮,然后数据保存是数据库,但数据没有显示在表格内的UI页面中,表格数据值显示但是立即隐藏。

这是我的代码

<form action ="/EmployeesStatus/empformsubmit"method="post">
        <table>

         <tr id="rowid">
          <td> <input type="hidden" id="empemailid" name="empemailname" value="${showid}" readonly="readonly"> </td> 

          <td> <strong> PROJECT NAME </strong> </td>
          <td class="s1"> <select id="listid" name="projectlist" class="projid" style="width:165px;padding:3px;" onchange="GetSelectedTextValue(this)"></select> </td>

          <td> <strong> TASK NAME </strong> </td>
          <td class="s1"> <select id="taskid" name="tasklist" class="tasksid" style="width:165px;padding:3px;"> </select></td>  

          <td> <strong> COMPLETE HOURS </strong> </td>
          <td class="s1"> <input type="text" id="emphours" name="hours" class="completehrs"> </td> 

           <td> <strong> COMPLETE DATE </strong> </td>
           <td class="s1"> <input type="date" id="date" name="dates" style="width:165px"> </td> 
         </tr>

         <tr>
            <td> <input type="submit" value="Submit" id="btn1" /> </td> 
            <td> <input type="button" value="LOGOUT" onclick="logoutPage()" id="btn2"/></td>
            <td> <input type="button" value="VIEW TASK LIST" onclick="viewemployeetasklist()" id="btn3"/></td>
         </tr>

        </table>
        </form>

        <table border="2px" id="table1">
            <tbody>
                <tr>
                <th> PROJECT ID </th>
                <th> TASK ID </th>
                <th> HOUR </th>
                </tr>
            </tbody>
        </table>

        <script type="text/javascript">

        $("#btn1").click(function(){

            var tbdy = $('#table1').children('tbody');
            var tables = tbdy.length ? tbdy : $('#table1');
            var name111 = $('.projid').val();
            var email111 = $('.tasksid').val();
            var dob111 = $('.completehrs').val();
            $("#table1").show();
            tables.append('<tr><td>'+name111+'</td><td>'+email111+'</td> 
           <td>'+dob111+'</td></tr>');
           })
           </script>

我尝试使用jquery但没有得到完美的解决方案

提前感谢你。

1 个答案:

答案 0 :(得分:0)

当您提交表单时,页面会重新加载。尝试触发提交事件并阻止重新加载。

您的问题并不是很清楚......如果您想要显示表单子目标所达到的数据,您可以这样做:

MoveThumb() 
{
    m_iMidPoint = Mouse.Cursor.Y;
    int iHalfThumb = ThumbLength / 2;
    m_iMidPoint += iHalfThumb;

    // Clamp to allowable range
    m_iMidPoint = m_iMidPoint < (TrenchStartPixel + iHalfThumb) 
        ? TrenchStartPixel + iHalfThumb 
        : m_iMidPoint;

    m_iMidPoint = m_iMidPoint > (TrenchEndPixel - iHalfThumb) 
        ? TrenchEndPixel - iHalfThumb 
        : m_iMidPoint;

    Value = MidThumbToValue(m_iMidPoint);           // This property gets clamped
}

public int ConvertRange( int originalStart, int originalEnd, int newStart, 
    int newEnd, int value) 
{
    double scale = (double)(newEnd - newStart) / (originalEnd - originalStart);
    return (int)(newStart + ((value - originalStart) * scale));
}

public int ValueToMidThumb(int iValue) 
{
    return ConvertRange(Minimum, Maximum, TrenchStartPixel + (ThumbLength/2), 
        TrenchEndPixel - (ThumbLength/2), iValue);
}

public int MidThumbToValue(int iValue) 
{
    return ConvertRange(TrenchStartPixel + (ThumbLength /2), 
        TrenchEndPixel - (ThumbLength /2), Minimum, Maximum, iValue);
}

https://jsfiddle.net/alexdant91/f7Lmh1jd/2/

&#34;我收到错误当我点击保存按钮&#34;请与我们分享错误,因为我们无法看到任何与数据库相关的代码。

既然你的问题不是很清楚,如果它不是你需要的,请告诉我们更多。