How can I create an HTA that enable close button after certain time period(15 sec)? - hta

How can I create an HTA that enable close button after certain time period(15 sec)?
Thank in advance.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Enable close button after 15 sec</title>
<script type="text/javascript">
window.onload = function(){
setTimeout(function(){
document.getElementById('close-button').style.display = 'inline';
}, 15000);
}
</script>
</head>
<body>
<input type="button" value="Close" name="close-button" id="close-button" style="display:none;" />
</body>
</html>

Related

Press Enter after submitting HTTP request

After I send the http request, I need to press the "enter" key immediately. Here's my code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<input id="approved_btn" value="Approve" class="btn" title="Approve" name="apv" type="submit" onclick="window.open('https://www.google.com')">
</body>
</html>
<script type="text/javascript">
if(document.URL.indexOf("") >= 0) {document.getElementById('approved_btn').click();
}
try {Typekit.load();} catch(e) {}
</script>
Right now it just opens Google in a new window and does not automatically press enter. Any help is greatly appreciated. Thank you!

My required field validation of jQuery is not working

I have aspx page where only one text box will be a required field. I am using JQuery to validate it.
My problem is the client side validation is not working.
The head section of my page is
<script src="../JavaScript/jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="../JavaScript/jquery.validate.js" type="text/javascript"></script>
<script src="../JavaScript/CandidateValidation.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
checkRequiredInputs();
});
</script>
The CandidateValidation.js file contains
function checkRequiredInputs(){
$(".requiredField").validate({
rules:{
txtFName:{required: true}
},
messages:{
txtFName:"Name Required"
}
});
}
I have a CSS CLass lin my CSS File like
.requiredField
{
}
The Text box where for this input is
I need a suggestion or solution from you programmers,the most helpful I have ever found, from this helpful sites, waiting for your reply. Thanx in advance
For the code to work you will need to call validate() on the form containing your textbox.
For example:
[WebForm1.aspx]
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Validation.WebForm1" %>
<!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 runat="server">
<link href="../Css/StyleSheet1.css" type="text/css" rel="Stylesheet" />
<script src="../JavaScript/jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="../JavaScript/jquery.validate.js" type="text/javascript"></script>
<script src="../JavaScript/CandidateValidation.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
checkRequiredInputs();
});
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server" clientidmode="Static" >
<asp:TextBox runat="server" ID="txtFName" />
</form>
</body>
</html>
[CandidateValidation.js]
function checkRequiredInputs(){
$("#form1").validate({
rules:{
txtFName:{required: true}
},
messages:{
txtFName:"Name Required"
}
});
}
Setting clientidmode="Static" on form1 will make it have same ID on client side so it can be referenced easily from jQuery.
If you press enter in txtFName TextBox to submit validation will be performed on the form:

Upload image at client side first

I have a file upload control in asp.net which is used to upload image file. Now what I want is I have image control so when a user uploads a file, The image from that file should be visible in the image control before it is really upload on the server. When ever user changes the file, the change should be reflected in that image control. I dont want to use any additional button other than file upload control.
Is there any way to do this with javascript??
I think thats possible in HTML5 supported browsers
check the HTML5 FILE API http://www.w3.org/TR/FileAPI/
This works in FF3+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>input type=file & Firefox 3</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<h1>This works in Firefox 3+</h1>
<script type="text/javascript">
// <![CDATA[
function inputFileOnChange() {
if (document.getElementById('fichier').files) {
$("#dvFileName").html(document.getElementById('fichier').files.item(0).name);
$("#imgImage").attr("src" ,document.getElementById('fichier').files.item(0).getAsDataURL());
};
};
// ]]>
</script>
<div>
<input type="file" name="fichier" id="fichier" onchange="inputFileOnChange();" />
<br /><br />
<img id="imgImage" src="" width="200" height="200" alt="" />
<div id="dvFileName">
</div>
</div>
</body>
</html>

Changing content on ASP.NET using AJAX

I have this asp.net code in my page :
<div id="prx">ABC</div>
And I want to change the value "ABC" to something when for example the user type a value in TextBox.
How can I do that using Ajax ?
Thanks
You don't need AJAX to do this. You can simply use Javascript to update the content of the DIV tag with the contents of the INPUT widget. See How to set the value of a form element using Javascript.
Now if you'd like to update the TextBox with something from the server without reloading the page, then that's AJAX. I'd use jQuery.ajax() function over UpdatePanels though. Here's a jQuery AJAX Tutorial.
May be using javascript?)
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication11.WebForm2" %>
<!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 id="Head1" runat="server">
<title></title>
<script type="text/javascript">
function setDivContent() {
var textInput = document.getElementById('text1');
var divPrx = document.getElementById('prx');
divPrx.innerHTML = textInput.value;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="prx">ABC</div>
<br />
<input type="text" id="text1" />
<button onclick="javascript:setDivContent(); return false;">Set</button>
</div>
</form>
</body>
</html>
Check out the ASP.NET AJAX UpdatePanel control. It lets you change text on a page and "AJAX-ifies" anything inside it, instead of doing a full postback. Here is a good tutorial on it.
I know this is old question.. but it might help someone
JQUERY for this would be :
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#btn1").click(function(e){
e.preventDefault();
$("#prx").text($("#text1").val());
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="prx">ABC</div>
<br />
<input type="text" id="text1" />
<button type="button" id="btn1">Set</button>
</div>
</form>
</body>
</html>

My jQuery is not working

<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!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 runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
$(".button1").click(function ()
{
$("p").hide("slow");
});
$(".button2").click(function ()
{
$("p").show("slow");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<input id="Button1" type="button" value="button" class="button1"/>
<input id="Button2" type="button" value="button" class="button2"/><h2>Welcome to F5 Technologies </h2>
<p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp F5 Technologies is a rapidly developing company, acquiring its position on the business market,
Our company helps make products
delivery more effective, efficient, and meaningful to our customers, and allow them to take greater
responsibility for their own new products.Software is developed by the most experienced development staffs. </p>
</form>
</body>
</html>
you need to include the jQuery library.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
You didn't include the jQuery library itself:
<script src="jquery.min.js" type="text/javascript">
</script>
You can also include it from a CDN:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"
type="text/javascript"></script>
Despite my comment on the question, it looks like the main culprit is that you aren't actually referencing the jQuery JS file. Try something like:
<script type="text/javascript" src="Scripts/jquery-1.3.2.js"></script>

Resources