Json header for prototype (PHP)

header(‘X-JSON: (‘ . json_encode($data) . ‘)’);

header(‘Content-type: application/x-json’);

echo json_encode($data);

Include javascript in an external js file

This is how to include a script into an external javascript file. This is also similar to PHP include() statement.

document.write(“<script type=’text/javascript’ src=’JAVASCRIPT_URL_JS’></script>”);

Change For Attribute for Label Tag

This is a way to change for attribute value for label with Javascript.

<label id=”myLabel” for=”something”>my label</label>

Normal way:

document.getElementById(‘myLabel’).htmlFor = “another thing”;

Prototype JS way:

$(‘myLabel’).htmlFor = “another thing”;