Javascript generating characters that are not present

Asked

Viewed 47 times

0

The code below is in XML and is a form that is being used for convenience generating code HTML, everything typed in the input will be sent to textarea already with the HTML through javascript.
The checkbox is with script for curb the confirmation button, and also generates HTML but instead of simply </div>\n</div> the result comes out as on</div>\n</div>, but has not on in string, what is this?

The form is hosted on blogger at this link.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'> 
  <head>
    <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/> 
    <b:if cond='data:blog.isMobile'> 
      <meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/> 
    <b:else/> 
      <meta content='width=1100' name='viewport'/> 
    </b:if> 
    <b:include data='blog' name='all-head-content'/> 
    <title><data:blog.pageTitle/></title>
   <b:skin><![CDATA[/*

]]></b:skin>

<style type='text/css'>
a:link {
    text-decoration: none;
    text-transform: uppercase;
    font-weight: bold;
    color: #5190e2;
}

a:visited {
    text-decoration: none;
    color: #5190e2;
}

a:hover {
    text-decoration: none;
    color: #3d679e;
}

a:active {
    text-decoration: none;
    color: #5190e2;
}
</style>


<style type='text/css'>
* {
    box-sizing: border-box;
}

input[type=text], select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
}

label {
    padding: 12px 12px 12px 0;
    display: inline-block;
}

input[type=submit] {
    background-color: #4CAF50;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    float: right;
    margin-top: 10px;
    margin-bottom: 10px;
}

input[type=submit]:hover {
    background-color: #45a049;
}

.container {
    border-radius: 5px;
    background-color: #f2f2f2;
    padding: 20px;
    width: 600px;
    margin: auto;
}

.conf {
    width: 30%;
    float: left;
    margin-top: 20px;
    margin-left: 280px;
}

.col-25 {
    float: left;
    width: 20%;
    margin-top: 6px;
}

.col-75 {
    float: left;
    width: 80%;
    margin-top: 6px;
}

/* Clear floats after the columns */
.row:after {
    content: &quot;&quot;;
    display: table;
    clear: both;
}

/* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
    .col-25, .col-75, input[type=submit] {
        width: 100%;
        margin-top: 0;
    }
}
</style>   
  </head>
  <body>

<div style='margin-top:50px; '><center><h1>LINKS</h1></center></div>  

<div class='container' style='margin-top:50px;'>
<form autocomplete='off' onsubmit='return submitted()'> 
  <div class='row'><div class='col-25'><label for='01'>SERVIDOR: </label></div><div class='col-75'><input id='01' name='link' required='required' type='text'/></div></div>
  <div class='row'><div class='col-25'><label for='02'>LINK: </label></div><div class='col-75'><input id='02' name='link' type='text'/></div></div>
  <div class='conf'>CONFIRMAR:<input id='myCheck' name='link' onclick='bloqueio()' type='checkbox'/></div>
  <div class='row'><input disabled='disabled' id='confirmar' type='submit' value='CONCLUIR'/></div> 
  <div class='row'><textarea name='link' style='height:200px'/></div> 
</form>
</div>

<div style='margin-top:50px; '> 
<center>
  <p class='author'>&#169; Gerador de postagens do <a href='https://www.nextdark.com/'> Next Dark</a> <b>By: Mark Vaaz</b></p></center></div>


  <b:section class='navbar' id='navbar' maxwidgets='1' showaddelement='no'/>


<script>
function bloqueio() {
    document.getElementById(&quot;confirmar&quot;).disabled = false;
}
</script>


<script>
function submitted() {


   if((document.getElementsByName(&quot;link&quot;)[0].value)!=&quot;&quot;){
     link0= &#39;&lt;div class=&quot;dropdown&quot;&gt;\n  &lt;button class=&quot;dropbtn&quot;&gt;&#39;+ document.getElementsByName(&quot;link&quot;)[0].value +&#39;&lt;/button&gt;\n  &lt;div class=&quot;dropdown-content&quot;&gt;\n&#39;;
   }else{
     link0=&quot;&quot;;
   }

   if((document.getElementsByName(&quot;link&quot;)[1].value)!=&quot;&quot;){
     link1= &#39;    &lt;a href=&quot;&#39;+ document.getElementsByName(&quot;link&quot;)[1].value +&#39;&quot; target=&quot;_blank&quot;&gt;LINK - 01&lt;/a&gt;\n&#39;;
   }else{
     link1=&quot;&quot;;
   }

   if((document.getElementsByName(&quot;link&quot;)[2].value)!=&quot;&quot;){
     link2= document.getElementsByName(&quot;link&quot;)[2].value +&#39;&lt;/div&gt;\n&lt;/div&gt;&#39;;
   }else{
     link2=&quot;&quot;;
   }

   var formValue = link0 + link1 + link2;
   document.getElementsByName(&quot;link&quot;)[3].value = formValue;
   return false;
}
</script>
  </body> 
</html>

Decoded scripts:

<script>
function bloqueio() {
    document.getElementById("confirmar").disabled = false;
}
</script>


<script>
function submitted() {


   if((document.getElementsByName("link")[0].value)!=""){
     link0= '<div class="dropdown">\n  <button class="dropbtn">'+ document.getElementsByName("link")[0].value +'</button>\n  <div class="dropdown-content">\n';
   }else{
     link0="";
   }

   if((document.getElementsByName("link")[1].value)!=""){
     link1= '    <a href="'+ document.getElementsByName("link")[1].value +'" target="_blank">LINK - 01</a>\n';
   }else{
     link1="";
   }

   if((document.getElementsByName("link")[2].value)!=""){
     link2= document.getElementsByName("link")[2].value +'</div>\n</div>';
   }else{
     link2="";
   }

   var formValue = link0 + link1 + link2;
   document.getElementsByName("link")[3].value = formValue;
   return false;
}
</script>

1 answer

1


This value is coming from your checkbox at this time

link2= document.getElementsByName("link")[2].value +'</div>\n</div>';

the value of checkbox is on...

  • It is really to come this checkbox value, but how do I not see the "on"?

  • excluding Document.getElementsByName("link")[2]. value

Browser other questions tagged

You are not signed in. Login or sign up in order to post.