how to pick up a value and post it on a modal?

Asked

Viewed 1,031 times

3

my html is like this:

<a href="#modal" data-toggle="modal" data-id="login">logar</a>

i need a php or javascript that does a post or onclick that sends the value "data-id='login'" to a get inside the modal .... in modal will have a get to take the value and make a

document.getElementById("login").innerHTML=xmlhttp.responseText; 

in the div "#login" within the modal


kind of:

      <a href="#modal" data-toggle="modal" onclick="post" value="var-1">logar1</a>
      <a href="#modal" data-toggle="modal" onclick="post" value="var-2">logar2</a>

when clicked it activates this modal here:

   <div class="modal fade" id="modal-formlogin">
   <?php
   $variable = $_GET["aqui o recebe o valor de value"];
   echo $variable;
   ?>
   </div>

i believe that I should use a javascript Jah that does not change page... the modal is on the same page, it is hidden but when active it appears and receives the value

  • Can you explain better what you mean by "for a get inside the modal"?

1 answer

1

Solved, It works perfectly:

<script src="js/jquery.min.js"></script>
<script>
var variavel='';
function setval(varval){
variavel=varval;
event.preventDefault();
$('#loadexternalfile').load(variavel);
return;
}
</script>

<button><a onclick="javascript:setval('test1.txt')" />teste 1</a></button>
<button><a onclick="javascript:setval('test2.txt')" />teste 2</a></button>

<div id="loadexternalfile"></div>

Browser other questions tagged

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