how to get a value and post it in a modal?

3

My html looks like this:

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

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

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

in div "#login" within modal

type like this:

      <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 the page ... the modal is on the same page, it is hidden but when activated it appears and receives the value

    
asked by anonymous 26.04.2016 / 20:12

1 answer

1

Solved, 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>
    
26.04.2016 / 21:25