|
JavaScript controls with date and time (format: dd / mm / yyyy hh: mm: ss) Thank you, and provide the connection site
|
|
|
|
|
Would you care to re-phrase that as a question?
It currently makes no sense at all.
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Can any one tell me how to hid the form details when I submit form to server.
|
|
|
|
|
The easy way is to use the POST method instead of GET for your form.
|
|
|
|
|
Submit as a POST request such that data is sent in form headers. If you do a GET, you would have to use querystring.
|
|
|
|
|
I see that IE(10), after changing an OPTION's .text property from within the OnChange event handler, the SELECT element becomes unclickable (like disabled) for the user.
HTML fragment to reproduce the behavior:
<form><select size=3 id=sel>
<option>one
<option>two
<option>three
</select>
<textarea name=debugga cols=40 rows=10>
</textarea></form>
<script>
document.forms[0].sel.onchange=function ()
{ var opt = this.options[this.selectedIndex];
this.form.debugga.value += "[click:"+opt.text+"] ";
opt.text += '#';
}
</script>
When using onclick instead of onchange, the problem does not appear.
When opening an alert box after the .text change (uncomment line 'now it works'), the problem does not occur either.
Has anyone an idea how to do a workaround or if Microsoft has already commented on this bug? I cannot find a single article about this issue. Thanks in advance!
|
|
|
|
|
Personally, I'd try fixing the HTML and trying again. (You haven't closed any of the 3 <option> tags)
<form>
<select size=3 id=sel>
<option>one</option>
<option>two</option>
<option>three</option>
</select>
<textarea name=debugga cols=40 rows=10></textarea>
</form>
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
you should test if your suggestion works before giving such an trivial answer. no -- it doesn't make any difference, since the closing tag for the option element is optional by specification.
|
|
|
|
|
You're welcome.
Your title clearly indicates a problem with IE10 - you sound like you know a way of testing with it without having it? I'd be most interested.
I offered a suggestion and (wrongly) implied that the html was broken. Sorry you feel so aggrieved.
I assume you get the same result when using addEventListener to attach the handler?
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Looks like a weird browser bug to me. I've had a play with your script and found an ugly workaround by blurring the select box in the onchange handler:
document.forms[0].sel.onchange = function() {
var opt = this.options[this.selectedIndex];
this.form.debugga.value += "[click:"+opt.text+"] ";
opt.text += '#';
this.blur();
}
|
|
|
|
|
I want to save a file in a folder.I have a textbox with browse button and [SAVE] button i could browse the file but i am not able to save that same file in that folder.
Its urgent plz help..
|
|
|
|
|
Because of security reasons, file system is not accessible in JavaScript. You can try to write an ActiveX but will only be for IE.
In HTML5, there is a new API that can help but it has limitations like specific browser versions support.
|
|
|
|
|
I am currently converting asp pages to User Controls. In one of these pages a javascript timer displays the current time into a text block. Currently, the asp pages uses the javascript below. How do I move the timer javascript to a asp User Control and initialize it when the control loads?
<script type="text/javascript">
window.setInterval('timer();',1000);
function timer()
{
var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("TimerValue").innerHTML=t;
}
</script>
Thanks,
Steve Holdorf
-- modified 2-Apr-13 6:31am.
|
|
|
|
|
Hi. Also, when I run the code I get the following exception:
http://localhost:49334/ScriptResource.axd?
Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.
parameter name element
And the code the execption is on in the debugger is:
throw Error .argument('element', Sys.Res.createNoDom);
|
|
|
|
|
I got it working. I had some commented out code in my Ajax portion that was causing the error!
Steve Holdorf
|
|
|
|
|
I'm going crazy here. I've used this code for years and never had a problem. I tested a previous version of the the regex string for Canadian Postal Codes and it worked fine. But today doing a DHL Shipping upgrade testing on Canadian Addresses, I can't get my Canadian Postal Code Regex to produce a match.
So I'm trying K1A 0G9, K8N 5W6, LDU 9Z0
for example. I ran some test in RAD Regex Expresson tester, and could not produce a match as well using
/^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$/
Wait, I just tried this and got a match with the RAD Regex Expression tester, hmm
^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ] \d[ABCEGHJKLMNPRSTVWXYZ]\d$
This seems to work with every variation in the RAD tester, maybe this one
^[ABCEGHJKLMNPRSTVXYabceghjklmnprstvxy]{1}\d{1}[A-Za-z]{1} *\d{1}[A-Za-z]{1}\d{1}$
Wish a real Canadian would enlighten me on this one.
I must admit the canadian postal code system is pretty slick, but not sure why I have so much trouble with it.
var match_b_PostalCode;
var re_Shipping_PostalCode_CA = new RegExp("^[ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJKLMNPRSTVWXYZ]( )?\\d[ABCEGHJKLMNPRSTVWXYZ]\\d$/i");
var re_Shipping_PostalCode_MX = new RegExp("^\\d{5}(-\\d{4})?$");
var re_Shipping_PostalCode_US = new RegExp("^\\d{5}(-\\d{4})?$");
var txt_Shipping_PostalCode = $('[id*="_txt_Modal_ShipRate_AddressInput_PostalCode_Field"]').val().toUpperCase().trim();
switch (countryCode_Value) {
case "CA":
match_b_PostalCode = re_Shipping_PostalCode_CA.exec(txt_Shipping_PostalCode);
case "MX":
match_b_PostalCode = re_Shipping_PostalCode_MX.exec(txt_Shipping_PostalCode);
case "US":
match_b_PostalCode = re_Shipping_PostalCode_US.exec(txt_Shipping_PostalCode);
}
|
|
|
|
|
Figured it out in jFiddler, I forgot to put breaks in the switch statement, stupid me!
|
|
|
|
|
Am not sure what I’ve done wrong. The below code is supposed to show the time and date as Time|Date: 16:08:24 31/3/2013, however its now showing up as Time|Date: 16:08:24 0/3/2013…
<script>
function startTime()
{
var today=new Date();
var d=today.getDay();
var dt=today.getDate();
var mt=today.getMonth() + 1;
var y=today.getFullYear();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML= "Time|Date:"+" "+h+":"+m+":"+s+ " " + d+"/"+mt+"/"+y;
t=setTimeout(function(){startTime()},500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
Note: Everything else is fine except for the date, what with it bring up '0' instead of '31'
|
|
|
|
|
You have used d instead of dt in getElementById line. Sunday = 0
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
So on my site I've got a panel that slides out using Jquery, in that panel / div I've put a HTML5 game, the game works fine as a stand alone html document but I wanted to add it as a little surprise into a slide panel, however for the life of me I cannot keep the focus on canvas.
I've tried setting the tab index in the css to 1.
Here's the code I'm using.
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
canvas.width = 512;
canvas.height = 480;
canvas.id="gameCanvas";
div = document.getElementById("slide-panel");
div.appendChild(canvas);
$(document).ready(function(){
$(".btn-slide").click(function(){
document.getElementById('gameCanvas').focus()
});
});
Simon Lee Shugar (Software Developer)
www.simonshugar.co.uk
"You can be a king or a street sweeper, but everybody dances with the grim reaper" - Robert Alton Harris
|
|
|
|
|
Try the JQuery focus(), it seems to work a little better. Fires the focus event...
$('#gameCanvas').focus();
|
|
|
|
|
Thanks I'm using .focus instead now, actually think its due to where I'm loading the script and how the Eventlistnerers are loaded, unfortunately lacked a lot of free time this week to experiment!
Simon Lee Shugar (Software Developer)
www.simonshugar.co.uk
"You can be a king or a street sweeper, but everybody dances with the grim reaper" - Robert Alton Harris
|
|
|
|
|
Not sure if this helps, noticed div had no var to represent the object before append, I like using css instead of the element attributes width and height.
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
canvas.style.display = block;
canvas.style.width = 512;
canvas.style.height = 480;
canvas.id="gameCanvas";
var div = document.getElementById("slide-panel");
div.appendChild(canvas);
|
|
|
|
|
jkirkerx wrote: I like using css instead of the element attributes width and height.
jkirkerx wrote: canvas.style.width = 512;
canvas.style.height = 480;
Setting the width and height of a canvas control via CSS has negative impacts associated with it. You need to set height and width via the element attributes.
I agree however that in situations outside of the canvas element you would want to set these via CSS.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
In my beginning, I used the width and height elements, but switched over to pure css later on in the years.
I know in HTML emails, I set both. I'll have to investigate the negative impacts because now I'm curious about it.
|
|
|
|