Extracted jquery samples


//read
var c = $("#divid").html();

//set
$("#divid").html("hello there");

//A field with an id "nameFID"
var name = $("#nameFID").val();
//trim it
name = $.trim(name);

$("#RegFormId").hide();
$("#SuccessfulRegistrationDivId").show();

$.ajax({
  url: url,
  cache: false,
  type: "POST"
}).done(showGoodRegistration);

$("#some-field-id").focus()

function resetForm()
{
    //alert("resetform");
    $("#SubjectFieldID").val("");
    $("#BodyFieldID").val("");
}

var poststuff = $("#UpdateSubmitFormID").serialize();
$.post("/akc/update",poststuff,replyFromPost);

function replyFromPost(data)
{
    dalert("reply:" + data);
    if (isAjaxSuccess(data) == false)
    {
        alert("Serverside error:" + data);
        return;
    }
    saveLocal(encodedAppendText);
}

How do you set class using jquery

Search for: How do you set class using jquery

You can use removeClass method

How do I query an html element in its hierarchy

Jquery selectors notes are here

form processing in jquery

Search for: form processing in jquery

How to select form objects in jquery

Search for: How to select form objects in jquery

Jquery docs on selectors

Documents on all selectors

Here is what I am looking for

2 hours running and I give up processign forms through Jquery :(


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.

jquery setting checked

Search for: jquery setting checked


function setSelectedSectionType(sectiontypeid)
{
    var sectiontypeRBId = "#SectionTypeRBID_" + sectiontypeid;
    $(sectiontypeRBId).prop("checked",true);
}