< >

action-attribuite-bei-submit-wechseln.php


Quell Code


<!DOCTYPE HTML>
<html lang="de">
<head>
<style>
body{
padding:20px;
}
*{
margin: 0;
padding:0px;
}
.tftextinput{
   font-family: Arial, Helvetica, sans-serif;
   font-size:14px;
   border:1px solid #0076a3; 
   border-bottom-left-radius:5px;
   border-bottom-right-radius:5px; 
}
</style>
<title>savepage</title>
</head>
<body>


<div id="tfheader">
   <form id="tfnewsearch" action="https://sebastian1012.bplaced.net/loesungen/html/action-attribuite-bei-submit-wechseln.php"> 
   <input class="tftextinput" id="text" size="21" maxlength="120" type="text" value="semiar"><br>
   <input value="GitHubUser" class="tfbutton" type="submit"></form>
</div>

<script>
window.addEventListener('DOMContentLoaded',function(){
    var ele=document.getElementById('tfnewsearch');
    ele.addEventListener("submit",function(evt){
       let alt=ele.getAttribute('action');
       let such_link=document.getElementById('text').value;
       let neuer_link=alt.replace('html',`${such_link}`)
       neu=ele.setAttribute('action',neuer_link);
       //ele.submit();
       // evt.preventDefault();
       console.log(ele.getAttribute('action'))
    });
});
</script>
</body>
</html>