-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_jsLibrary.js
executable file
·70 lines (53 loc) · 1.41 KB
/
example_jsLibrary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* ------------------------------------------------------------------
A set of simple functions to demonstrate AjaxServerResponseHander
------------------------------------------------------------------- */
function submitForm(formName) {
AjaxServerResponseHander.submitForm(formName, 'example_ajax.php');
}
function sendPostData(dataString, url){
if(typeof url==='undefined'){
url='example_ajax.php';
}
AjaxServerResponseHander.postData(dataString, url);
}
function clearContent(id) {
var cont = document.getElementById(id);
if(cont.childNodes.length){
cont.removeChild(cont.childNodes[0]);
}
}
function cleanHTML(id) {
var element=document.getElementById(id);
if(element!=null){
element.innerHTML='';
}
}
/*
values for pos argument in function appendHTML():
<!-- beforebegin -->
<p>
<!-- afterbegin -->
foo
<!-- beforeend -->
</p>
<!-- afterend -->
@param id - id of the html element where we want to append html code
@param pos - position where we want to append html code (see above for the values)
@param html - html code
*/
function appendHTML(id, pos, html) {
document.getElementById(id).insertAdjacentHTML(pos, html);
}
function showHide(id, show, display) {
var ht=document.getElementById(id);
if(show==1){
ht.style.display=display;
}
else{
ht.style.display='none';
}
return
}
function setStyle(id, attribute, style) {
document.getElementById(id).style[attribute]=style;
}