Doubts HTML sum of attributes

0

Hello, I have the following question, I'm developing an application and I need to know how I could add a text attribute (as a form) to a link.

Note: no need to use document.getelementbyid.

Example: link + text typed in a text area.

I'll paste my code

<form 
  action="http://teste.com.br/ 
  method="POST" 
  onSubmit="this.BTEnvia.value='Enviando...'; 
  this.BTEnvia.disabled=true;">

ai within this link wanted to paste a text typed by the user

user example typed "example" at the time that you can add this link of form action + the text that he typed in the "example" case

In the way you can open this link with form action.

Is anyone willing to help me?

    
asked by anonymous 09.07.2018 / 16:26

2 answers

0

Hello @ sev3ndie,

You can perform the submit with ajax,

js:

$("#form1").submit(function(){

    $.ajax({
      url:"get_link.php",
      success:function(data){
           window.open("http://site.com.br/"+data);
          }
    });

    return false

});//end submit

get_link.php:

<?php

   $get_link = $_POST['get_link'];
   echo $get_link;

?>
    
09.07.2018 / 16:42
0

I did not quite understand, but would that be?

function myNewUrl(url, action, val){
    return url +'?' + action + '=' + val;
}

document.querySelector('.my_form').addEventListener('submit', function(a){
   a.preventDefault();
   let valor = document.querySelector('.my_input').value;
   console.log(myNewUrl('http://minhaurl.com/', 'minhaAction', valor));
});
<form class="my_form" method="POST">
  <input type="text" placeholder="Digite o action" class="my_input"/>
  <button>Enviar</button>  
</form>

Only change the console.log by the redirect function. If not, please explain your question better as it is very difficult to answer.

    
09.07.2018 / 16:53