Vorlesungen
  Download     DBS     Sprachen     Oberflächen     Impressum     Datenschutz  
1. Sem
2. Sem
3. Sem
4. Sem
Entw. von multimedialen Anwendungen
Web-Technologien
Webprogrammierung
5. Sem
Wahlpflicht-SoSe
Wahlpflicht-WiSe
IEA-2019
Projektwochen
Allgemein:
Startseite
Vorlesungen
Labore
Sinnvolle Programme
Lineare Regression
GUI-Entwurfsarbeit
Single-Format
Design Pattern-Termine
Observer1
Bsp2
Json-Array
Json-Dialogelemente
Webtechnologien

javascript-snippets

JavaScript Bereich
<script type="text/javascript">
// <![CDATA[
"use strict";
function calc( form ) {
"use strict";
alert ("here in f") ;
} // function calc
// ]]>
</script>externes Javascript
<script type="text/javascript" src="bsp.js"></script>


Function
function f() {
"use strict";

return;
}


console.log
console.log( "hier beim Punkt1" );


onload-Event
window.onload = function() {
" use strict";
} // onload


getElementById
let element = document.getElementById("id");


innerHTML
element.innerHTML = '<h2>Hier ist eine Überschrift</h2>';
element.style.display = 'block'; // Einschalten
element.style.display = 'none'; // Ausschalten

AJAX-Bereich
<script type="text/javascript">
// <![CDATA[
"use strict";

let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = readajax;function startAjax(form) {
"use strict";
let param = "Ajaxb.jsp?Wert="123"&Name=strName;
alert(param);
xmlhttp.open("GET", param);
xmlhttp.send();
} // cstartAjax


function readajax() {
"use strict";
// alert(xmlhttp.readyState);
let elementAjax = document.getElementById("ajax");
if (xmlhttp.readyState == 4) {
//alert(xmlhttp.responseText);
//elementAjax.innerHTML= xmlhttp.responseText;

// let obj = JSON.parse(xmlhttp.responseText);
elementAjax.innerHTML = "<h2> Ajax Text </h2> ";
} // if
} //readajax

// ]]>
</script>


access to checkbox
if (form.myChk.checked ) {
}


access to radiobutton
let select=""
for (var i=0; i<form.rb.length; i++) {
if (form.rb[i].checked) {
select = form.rb[i].value;
} // if
} // for access to ComboBox
index = form.myCombobox.selectedIndex; // form.myCombobox.options[i].value



access to ComboBox (Multiple)
for (i = 0; i < form.wochentag.length; i++) {
if (form.wochentag.options[i].selected) {
alert("Gewählter Index: " + (i) + "
" + form.wochentag.options[i].value);
} // if
} // for


parseInt
let n = parseInt(sn);


parseFloat
let n = parseFloat(sn,10);


IsNaN
if ( isNaN(sn) ) {

}
else {

} // if isNaN


String methods
let n = str_input.length;
.indexOf("abc"); // return the position of abc, -1=not found, no regular expression, faster
item = item.replace("abc", "xyz");
// extract from the string, start, end (0->n-1)
// startindex<y0, then it start from the end
.slice(1,5);
var items = mystring.split(','); // split the string between the comma
.substr(1,5); // start<= chars <= end; (0->n-1)
.substring(1,5); // start<= chars < end; (0->n-1)
.toLowerCase();
.toUpperCase();
.trim(); // remove the spaces at the start and endArray
let n = str_input.length;


Regex
let regex = new RegExp('^[A-ZÄÖÜ]{1,1}[a-zäüöß]{1,29}$');
if (!regex.test(form.firstname.value)) {
alert('Fehlerhafter Vorname');
return;
}


forms-snippets
php-snippets