Extracted jquery samples
satya - Mon Oct 01 2012 12:18:33 GMT-0400 (Eastern Daylight Time)
How to read/set a div
//read
var c = $("#divid").html();
//set
$("#divid").html("hello there");
satya - Tue Oct 02 2012 11:08:47 GMT-0400 (Eastern Daylight Time)
How to read a value from a field
//A field with an id "nameFID"
var name = $("#nameFID").val();
//trim it
name = $.trim(name);
satya - Tue Oct 02 2012 11:10:01 GMT-0400 (Eastern Daylight Time)
Hiding and showing divs
$("#RegFormId").hide();
$("#SuccessfulRegistrationDivId").show();
satya - Tue Oct 02 2012 11:11:06 GMT-0400 (Eastern Daylight Time)
an ajax get
$.ajax({
url: url,
cache: false,
type: "POST"
}).done(showGoodRegistration);
satya - Tue Oct 02 2012 11:12:06 GMT-0400 (Eastern Daylight Time)
Showing focus
$("#some-field-id").focus()
satya - Tue Oct 02 2012 14:07:43 GMT-0400 (Eastern Daylight Time)
Setting the field values
function resetForm()
{
//alert("resetform");
$("#SubjectFieldID").val("");
$("#BodyFieldID").val("");
}
satya - Tue Oct 02 2012 14:45:08 GMT-0400 (Eastern Daylight Time)
Here is how you post
var poststuff = $("#UpdateSubmitFormID").serialize();
$.post("/akc/update",poststuff,replyFromPost);
satya - Tue Oct 02 2012 14:45:38 GMT-0400 (Eastern Daylight Time)
Here is the replyFromPost method
function replyFromPost(data)
{
dalert("reply:" + data);
if (isAjaxSuccess(data) == false)
{
alert("Serverside error:" + data);
return;
}
saveLocal(encodedAppendText);
}
satya - Wed Nov 21 2012 12:44:04 GMT-0500 (Eastern Standard Time)
How do you set class using jquery
How do you set class using jquery
satya - Wed Nov 21 2012 12:45:28 GMT-0500 (Eastern Standard Time)
You can use removeClass method
satya - 5/16/2014 10:54:18 AM
How do I query an html element in its hierarchy
satya - 5/16/2014 10:58:32 AM
form processing in jquery
form processing in jquery
satya - 5/16/2014 11:02:15 AM
How to select form objects in jquery
How to select form objects in jquery
satya - 5/16/2014 12:06:57 PM
2 hours running and I give up processign forms through Jquery :(
2 hours running and I give up processign forms through Jquery :(
satya - 5/16/2014 12:12:18 PM
Lot more easier to do it natively in html
function createUser()
{
alert("Creating a user");
if (validateRequired(mainform,"userIdTextBox,passwordTextBox,emailTextBox") == false)
{
return;
}
if (mainform.passwordTextBox.value != mainform.rPasswordTextBox.value)
{
alert("Both password fields should have the same value");
return;
}
fieldValues = getAllFieldValues(mainform);
mainform.fieldValues.value = fieldValues;
mainform.action="/akc/update";
alert(fieldValues);
mainform.submit();
}
function onLoadFunction()
{
alert('onloadfunction');
fieldValues = "{{fieldValues}}";
if (fieldValues != "")
{
setFieldValues(mainform,fieldValues);
}
}
You can address the forms and its fields by name nicely and they are available as js objects.
satya - 5/23/2014 4:56:16 PM
jquery setting checked
jquery setting checked
satya - 5/23/2014 4:56:30 PM
You can do this
function setSelectedSectionType(sectiontypeid)
{
var sectiontypeRBId = "#SectionTypeRBID_" + sectiontypeid;
$(sectiontypeRBId).prop("checked",true);
}