隐藏的DOM元素包含消息并使其可见 [英] Hidden DOM element containing the message and to make it visible

查看:104
本文介绍了隐藏的DOM元素包含消息并使其可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用隐藏的DOM元素在点击提交按钮上显示消息请稍等处理,其中包含消息并使其可见,但消息未显示。


$ b $

 < form name =siteSearchForm方法= post&#160;<%= request.getContextPath()%> / servlet / visibilityControlleronsubmit =javascript:return validate(); on_load()> 
< td align =centerwidth =10%>< input type = submit name =siteSearchSubmitvalue =SUBMIT>& nbsp;< input type =RESET name =clearTNvalue =RESET>< / td>
< / form>

我通过调用 on_load onsubmit 中的表单标签上,但它没有显示消息

 <头> 
< script type =text / javascript>
函数on_load(){
var y = document.getElementById(txtHiddenUname);
y.type =text;
}
< / script>
< / head>

< body>
< input type =hiddenid =txtHiddenUnamevalue =invalid input/>
< / body>


解决方案

因为return语句会退出函数调用,之后它会运行。您需要在返回前添加它。

  onsubmit =on_load(); return validate(); 

或者您可以做

  onsubmit =return validate()&& on_load(); 

但您的on_load函数需要返回true。

  function on_load(){return true; } 

此外,为什么您使用输入来显示消息?看起来像你应该使用一个显示无/块的段落。 javascript:在事件处理程序中不需要,on_load似乎应该在窗口加载时调用,而不是表单提交。

I need to show message "Please wait Processing" on click of Submit button using a hidden DOM element which contains the message and make it visible, but the message is not showing.

My html for the form and my validate function are given below.

<form name="siteSearchForm" method=post action="<%=request.getContextPath()%>/servlet/visibilityController" onsubmit="javascript:return validate();on_load()">
    <td align="center" width="10%"><input type=submit name="siteSearchSubmit" value="SUBMIT" >&nbsp;<input type="RESET" name="clearTN" value="RESET"></td>
</form>

I tried the below code by calling on_load on form tag during onsubmit but it is not showing message

<head>
    <script type="text/javascript">
        function on_load(){
            var y = document.getElementById("txtHiddenUname");
            y.type= "text";
        }
    </script>
</head>

<body>
    <input type="hidden" id="txtHiddenUname" value="invalid input" />
</body>

解决方案

Becuase the return statement will exit the function call and nothing after it will run. You would need to add it BEFORE the return.

onsubmit="on_load(); return validate();"

or you can do

onsubmit="return validate() && on_load();"

but your on_load function needs to return true.

function on_load(){  return true; }

Also why are you using an input to display a message? Seems like you should be using a paragraph with display none/block. javascript: is not needed in event handlers, and on_load seems like it should be called on window load, not a form submission.

这篇关于隐藏的DOM元素包含消息并使其可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆