Doubt HTML attribute sum

Asked

Viewed 71 times

0

Good morning, I have the following doubt, I am 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: http://teste.bla.bla/ + the 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 inside this link wanted to paste a text typed by the user

example user typed "example" ai when that submite adds this form action link + the text that he typed in the "example"

How to open this link with form action.

Someone’s willing to help me ?

  • 2

    Hi, can you explain the question further?

  • 1

    Why it has to be a textarea and not an input text, which would be the most appropriate?

  • Why can’t you use document.getElementById ?

2 answers

0

Hello @sev3ndie,

you can perform 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;

?>
  • Vish face has another alternative ? ajax no manjo.

  • Check out @Lucas Carvalho, it seems that is within the idea

0

I didn’t quite understand it, but that would be it?

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>

Just replace the console.log with the redirect function. If not, I ask you to explain your question better as it is very difficult to answer.

Browser other questions tagged

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