Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Javascript POST an PHP (Anfänger)
#9
Tongue 
hier der ganze js code ! es wird kein post gesendet? verstehe es nicht  (
Code:
 lnk.onclick = myFunction_loeschen;
)

Code:
maxid = 0;
last = null;

function setdata(){
    table = document.getElementById("scrollContent_unerledigt");
    
    $.get("./alarmdb.php", function(data) {
        for ( let elem of data.getElementsByTagName('data') ){
                
                id = elem.getElementsByTagName('id')[0].firstChild.nodeValue;
                i = parseInt(id);
                if (maxid < id) {
                
                    maxid = i;
                    line  = document.createElement('tr');
                    
                    //Zustaendigkeit
                    field = document.createElement('td');
                    font = document.createElement('font');
                    adress = elem.getElementsByTagName('kreis')[0].firstChild.nodeValue;
                    font.innerHTML = adress;
                    field.appendChild(font);
                    field.setAttribute('width', 40);
                    line.appendChild(field);
                    
                    //Flags
                    field = document.createElement('td');
                    text = elem.getElementsByTagName('flags')[0].firstChild.nodeValue;
                    image = document.createElement('img');
                    if (text=='0') { image.src = 'web_images/Alarm_10.png'}
                    if (text=='1048576') { image.src = 'web_images/Alarm_9.png'}
                    if (text=='537919488') { image.src = 'web_images/Alarm_9.png'}
                    field.appendChild(image);
                    field.setAttribute('width', 40);
                    line.appendChild(field);

                    //Datum
                    field = document.createElement('td');
                    font = document.createElement('font');
                    font.innerHTML = elem.getElementsByTagName('datum')[0].firstChild.nodeValue;
                    field.appendChild(font);
                    field.setAttribute('width', 160);
                    line.appendChild(field);
                
                    //Address
                    field = document.createElement('td');
                    font = document.createElement('font');
                    adress = elem.getElementsByTagName('adresse')[0].firstChild.nodeValue;
                    font.innerHTML = adress;
                    field.appendChild(font);
                    field.setAttribute('width', 90);
                    line.appendChild(field);
                    
                    //Subaddress
                    field = document.createElement('td');
                    text = elem.getElementsByTagName('flags')[0].firstChild.nodeValue;
                    group = elem.getElementsByTagName('gruppe')[0].firstChild.nodeValue;
                    image = document.createElement('img');
                    if (adress[7]=='a') { image.src = 'web_images/Alarm_14.png'}
                    if (adress[7]=='b') { image.src = 'web_images/schnecken.png'}
                    if (adress[7]=='c') { image.src = 'web_images/Alarm_12.png'}
                    if (adress[7]=='d') { image.src = 'web_images/Alarm_7.png'}
                    field.appendChild(image);
                    field.setAttribute('width', 40);
                    line.appendChild(field);
                    
                    //Bezeichnung
                    field = document.createElement('td');
                    font = document.createElement('font');
                    font.innerHTML = elem.getElementsByTagName('bezeichnung')[0].firstChild.nodeValue;
                    field.appendChild(font);
                    field.setAttribute('width', 350);
                    line.appendChild(field);
                    
                    //Icon
                    field = document.createElement('td');
                    text = elem.getElementsByTagName('flags')[0].firstChild.nodeValue;
                    group = elem.getElementsByTagName('gruppe')[0].firstChild.nodeValue;
                    image = document.createElement('img');
                    if (group=='RETTUNG') { image.src = 'web_images/rettung_2.png'}
                    if (group=='NAVI') { image.src = 'web_images/Alarm_16.png'}
                    if (group=='SIRENE') { image.src = 'web_images/Alarm_11.png'}
                    if (group=='SERVICE') { image.src = 'web_images/Alarm_6.png'}
                    if (group=='EINZELRUF') { image.src = 'web_images/Alarm_8.png'}
                    if (group=='FAHRZEUG') { image.src = 'web_images/fahrzeug.png'}
                    if (group=='TORSTEUERUNG') { image.src = 'web_images/einstellungen.png'}
                    if (group=='UNWETTER') { image.src = 'web_images/regen.png'}
                    if (group=='DATAFILE') { image.src = 'web_images/file.png'}
                    if (group=='WETTER') { image.src = 'web_images/regen.png'}
                    if (group=='SWISSPHONE') { image.src = 'web_images/herunterladen.png'}
                    if (group=='MESSAGE') { image.src = 'web_images/email.png'}
                    if (group=='SYSTEM') { image.src = 'web_images/settings.png'}
                    if (group=='KRANKENTRANSPORT') { image.src = 'web_images/krankentransport_1.png'}
                    if (group=='FEUERWEHR') { image.src = 'web_images/feuerloescher.png'}
                    if (group=='UEBEROERTLICH') { image.src = 'web_images/server_5.png'}
                    if (group=='MULTIMASTER') { image.src = 'web_images/warnen.png'}
                    field.appendChild(image);
                    field.setAttribute('width', 40);
                    line.appendChild(field);
                
                    //Kommune
                    field = document.createElement('td');
                    font = document.createElement('font');
                    font.innerHTML = elem.getElementsByTagName('kommune')[0].firstChild.nodeValue;
                    field.appendChild(font);
                    field.setAttribute('width', 180);
                    line.appendChild(field);    

                    //Hinweis
                    field = document.createElement('td');
                    font = document.createElement('font');
                    font.innerHTML = elem.getElementsByTagName('hinweis')[0].firstChild.nodeValue;
                    field.appendChild(font);
                    field.setAttribute('width', 180);
                    line.appendChild(field);
                    
                    //Standort
                    field = document.createElement('td');
                    font = document.createElement('font');
                    font.innerHTML = elem.getElementsByTagName('wache')[0].firstChild.nodeValue;
                    field.appendChild(font);
                    field.setAttribute('width', 200);
                    line.appendChild(field);
                    
                        //Memo
                    field = document.createElement('td');
                    image = document.createElement('img');
                    image.src = 'web_images/file.png';
                    lnk = document.createElement('a');
                    //ink.href = '?modal=' + id;
                    lnk.onclick = myFunction_anlegen;
                    //lnk.onclick = $('#myModal3').modal();
                    //lnk.class = 'data-confirm';
                    lnk.appendChild(image);
                    field.appendChild(lnk);
                    field.setAttribute('width', 40);
                    line.appendChild(field);
                    
                    //Id
                    field = document.createElement('td');
                    font = document.createElement('font');
                    adress = elem.getElementsByTagName('id')[0].firstChild.nodeValue;
                    font.innerHTML = adress;
                    field.appendChild(font);
                    field.setAttribute('width', 90);
                    line.appendChild(field);
                    
                    //Loeschen
                    field = document.createElement('td');
                    image = document.createElement('img');
                    image.src = 'web_images/loschen_2.png';
                    lnk = document.createElement('a');
                    //lnk.href = '?test=' + id;
                    lnk.onclick = myFunction_loeschen;
                    lnk.appendChild(image);
                    field.appendChild(lnk);
                    field.setAttribute('width', 40);
                    line.appendChild(field);
                    
                    //-----------------------------------------------------------------------------------------------------
                    
                    
                    if (last)
                        {
                            table.insertBefore(line, last);
                        }
                    else
                        {
                            table.appendChild(line);
                        }
                    last = line;

                }


                
            // console.log(elem.getElementsByTagName('id')[0].firstChild.nodeValue);
        }
    });    
}

// Seite geladen
$(function() {
  setdata();    
});
        
//Uhrzeit
function ticken(){
var stunden, minuten, sekunden;
var StundenZahl, MinutenZahl, SekundenZahl;
var heute;

heute = new Date();
StundenZahl = heute.getHours();
MinutenZahl = heute.getMinutes();
SekundenZahl = heute.getSeconds();

if (StundenZahl < 10) {stunden = "0" + StundenZahl + ":";}
  else {stunden = StundenZahl + ":";}
if (MinutenZahl < 10) {minuten = "0" + MinutenZahl + " ";}
  else {minuten = MinutenZahl + " ";}
if (SekundenZahl < 10) {sekunden = "0" + SekundenZahl + " ";}
  else {sekunden = SekundenZahl + " ";}
zeit = stunden + minuten + " Uhr";
uhr.innerHTML = zeit;
setdata();

window.setTimeout("ticken();", 1000);
}

window.onload = ticken;  

function myFunction_anlegen() {
    $('#myModal3').modal();
    
}


function myFunction_loeschen() {
    
   $.ajax({
        type: "POST",
        url: "monitorOESoft.php",
        data: {test},
        cache: false,

        success: function(){
            alert("OK");
        }
    });
    
    
  }

 
  function myFunction_pager() {
    
    $('#myModal3').modal();

}

PHP-Code:
if(isset($_POST['test'])) {

              echo "gelöscht !";


fehler gefunden!

clear=22 


Code:
data: {confirm:'',clear:22},
Zitieren


Nachrichten in diesem Thema
RE: Javascript POST an PHP (Anfänger) - von black79 - 18.05.2022, 07:02

Gehe zu:


Benutzer, die gerade dieses Thema anschauen:
2 Gast/Gäste