通过 javascript 将值从子页面返回到父页面时面临的问题.它正在返回对象,我想要值

Issue facing while returning values from child to parent page via javascript. It is returning object and i want the value

本文关键字:返回 问题 我想要 对象 javascript 通过      更新时间:2023-09-26

我有一个javascript函数,如果用户选择将来的日期,则会出现一个弹出窗口,该弹出窗口将包含一个文本框和一个按钮。用户在文本框中输入值,然后单击弹出的子按钮。我想在父窗口中捕获这些值,但我无法做到这一点。

以下是我写的javascript:-

 function CheckDateEalier(sender, args)
     {
        var toDate = new Date();
        toDate.setMinutes(0);
        toDate.setSeconds(0);
        toDate.setHours(0);
        toDate.setMilliseconds(0);
        if (sender._selectedDate < toDate)
         {
            alert("You can't select day earlier than today! In Case if you are selecting Previous date then, By default it will take current Date.");
            sender._selectedDate = toDate;
            //set the date back to the current date
            sender._textbox.set_Value(sender._selectedDate.format(sender._format))
        }
        if (sender._selectedDate > toDate) {
            var timeSpent = window.open("EnterTimeSpent.aspx", "List", "scrollbars=no,resizable=no,width=320,height=100");
            document.getElementById('<%= hiddenFieldFutureDateSelectTimeSpent.ClientID%>').value = timeSpent;
        }
    }

子页面上的JavaScript:-

<script language="javascript" type="text/javascript">
function Parent() {
    var timespent = Input.elements["timespent"].value; 
    //window.opener.UpdateValues(3);
    window.returnValue = timespent;
    self.close();
}

子页面代码隐藏:-

<form name="Input" method="post" action="">
     <table>
       <tr>
       <td><input type="text" name="timespent" style="font-size:small;font-weight:bold;"></input>
       </tr>
       <tr>
       <td>
       <input type="button" value="Submit"  class="button small green rounded"   onClick="Parent()"></input>
       </td></tr>
     </table>
</form>

当我在调试时,我发现在父页面上,我无法捕获从孩子发送所花费的时间,它将其显示为对象。请帮助我弄清楚我正在犯的错误以及我如何在父级中捕获子页面文本框的值。

为什么不使用已经具有此功能的"提示";

var t=prompt("timespent",");

如果你需要样式,你可以使用jprompt(http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs)