jQuery localization calling setdefauls vs datepicker() - debugging

Can anyone tell me why this happens.
The following code works perfectly, I get the datepicker in German:
<input id="foo" type="text"> pick it
<script>
$(function() {
$( "#foo" ).datepicker();
$.datepicker.setDefaults( $.datepicker.regional[ "de" ] );
});
</script>
But the following code doesn't work (I get the datepicker in Japanese):
<input id="foo" type="text"> pick it
<script>
$(function() {
$( "#foo" ).datepicker();
$( "#foo" ).datepicker( $.datepicker.regional[ "de" ] );
});
</script>
Here are my include files :
http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/i18n/jquery-ui-i18n.min.js
Side note. According to the docs http://jqueryui.com/demos/datepicker/ it should work. Can anyone reproduce this?

If you your regional code is not recognized by the plugin it sets japanese...
http://jsfiddle.net/IrvinDominin/rGpCE/1/
I reproduce it; you can change your code in this way:
$(function() {
$("#foo").datepicker();
$("#foo").datepicker("option", $.datepicker.regional["de"])
});
Updated fiddle: http://jsfiddle.net/IrvinDominin/rGpCE/2/

Related

ajax. access hidden value of html in div

I Wanna access the hidden values in ajex posted in a div
<input type="button" value="button 1" class="btn">
<div id="div"><div>
<script>
$.ajax({
url:"btn2.php", success:function(data){
$('#div').html(data);}
});
$( "#table" ).on( "click", ".upd", function() {
alert("button is wrking");
});
</script>
PHP
echo"<input type='button' value='button 2' class='btn'>
<input type='hidden' value='dishonest' id='hdn'>";
can any one help me on this.. i have no idea what to do ...
basically i want value of hidden
var h=$('#hid').val();
but that doesn't work bcoz its posted later in div ...
You will get value from ajax success
success:function(data){
$('#div').html(data);
var h=$('#hid').val();
alert(h);
}

Input Button as Input image will not work

On my website i have a button which when clicked takes you to one of two random youtube videos. However i would like to change this to a image in stead of a button.I have tried to change it to a INPUT type="image" but this doesn't work. Here is the code i am using.
<SCRIPT language="JavaScript">
<!--
function get_random()
{
var ranNum= Math.floor(Math.random()*2);
return ranNum;
}
function getaGame()
{
var whichGame=get_random();
var game=new Array(2)
game[0]= "https://www.youtube.com/watch?feature=player_detailpage&v=NcFQF3PZFRk#t=722s";
game[1]= "https://www.youtube.com/watch?v=klBAW4MQffU";
location.href = game[whichGame];
}
//-->
</SCRIPT>
<FORM name="form1">
<center>
<INPUT type="button" onClick="getaGame()" >
</center>
</FORM>
Thanks for any help
An onclick event can be fired from any element. Here are some examples!

How to use MathJax in a form?

I have a textbox in a form and I want to use MathJax.I have downloaded it, but don't know how to use it.
I am using ASP-MVC3.
Thanks for your helps.
I found the issue.Its just needed to load js files from mathjax.org and add these lines to the head tag.
<script type="text/javascript">
$(document).ready(function () {
MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "all" } } });
});
</script>
<script src="~/Scripts/MathJax.js?config=Tex-AMS_HTML"></script>
And now its just needed to add the characters $$ and \\ to the text in the following form and append it to something like a div.
jQuery("#radikal").on('click', function () {
var x="$$\\sqrt[3]{8}$$";
$("#formul").append(x);
});
<input type="button" id="radikal"/>
<div id="formul"></div>
And now we will have a radical in div#radikal.
Thats all.

jquery form plugin does not working

i am a newbie programmer.I am stuck for two days with a simple code.I try to use jquery form plugin for submitting a form to another page and get a feedback from that page.The problem is the plugin is not working.the form is submitted as normaly without feedback.Here is the code
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<div id='preview'></div>
<form action='ajaxcall.php' id='upload_pic' enctype='multipart/form-data' method='post'>
<input type='file' id='pic' name='picture'>
<input type='submit' id='sub'>
</form>
var options=
{
target:'#preview',
url:'ajaxcall.php'
};
$(document).ready(function(){
$("#sub").click(function(){
$('#preview').html("<img src='images/loader.gif' alt='Loading.....'/>");
$('#upload_pic').ajaxForm(options).submit();
});
});
Here is my ajaxcall.php page code
if(!empty($_FILES['picture']['size']))
{
echo "<img src='images/197.jpg'>";
}
Expectation was the echoed image would feddback but the page is simply redirected to ajaxcall.php page.ajaxForm() function is not working.But why?please help.Thanks in advance.
Just replace your submit button for a normal one, because you are already submiting the form programatically from your click handler, so replace your following html:
<input type='submit' id='sub'>
for this one:
<input type='button' id='sub'>
use these codes instead of your script codes. sorry for the late answer
$(document).ready(function(){
$("#sub").click(function(){
var options=
{
target:'#preview',
url:'ajaxcall.php'
};
$('#preview').html("<img src='images/loader.gif' alt='Loading.....'/>");
$('#upload_pic').ajaxForm(options).submit();
});
});

document.getElementById("id").value = ""; Not working

The code for example document.getElementById("id").value="value"; is not working. I have assigned it on a function to replace the current value of the textbox once the page is loaded.
here is my code
<script type="text/javascript">
function rplace(){
document.getElementById('idtext').value="New Value";
}
onload=rplace
</script>
<form>
<input type="text" id="idtext" name="idtext" value="">
</form>
use jquery insteat of javascript.
$(document).ready(function(){ $("#idtext").val("New Value")});
Refer this

Resources