Reputation: 1102
How to post a value from div when click on button.
I have tried to leave the action blank so it will refresh the site when pressing the button. But the value does not come to? I only want TransID to post when pressing the button.
<form action=" ">
<div class="white-box">
<div class="row-fluid">
<div class="span3">TransID</div>
<div class="span3">Medlemsnummer</div>
<div class="span4">Beskrivelse</div>
<div class="span2">Indløs</div>
</div>
<?php
foreach($Test as $key){
?>
<div class="well">
<div class="row-fluid">
<div class="span3" id="TransNR" >#<?= $key['TransID']; ?></div>
<div class="span3"><?= $key['member_id']; ?></div>
<div class="span4"><?= $key['title']; ?></div>
<?php
$indløst = isset($key['indløst'])?($key['indløst']) :"";
?>
<?php
if($indløst)
{
?>
<div class="span2" ><?= date('d-m-y H:i:s', $indløst) ?></div>
<?php
}
else
{
?>
<input class="span2" type="submit" value="Ja ">
<?php }
?>
</div>
</div>
<?php
}
?>
</div><!-- / white-box -->
</form>
Upvotes: 0
Views: 97
Reputation: 301
Do something like this..
<a rel="tooltip" class="btn btn-mini" href="javascript:void(0)" onClick="somefunction('<?=$key['TransID']?>');" id="somefunction" data-original-title="somefunction">Some text </a>
Or
<a rel="tooltip" class="btn btn-mini" href="somefile.php?id=<?=$key['TransID']?>" >Some text </a>
Upvotes: 0
Reputation: 41595
You could use a hidden input to store the variable:
<input type="hidden" name="TransID" value="<?= $key['TransID']; ?>" />
Your form will send it by GET
method as you are not specifying the method
to be sent.
If you want to send it by POST
, change your form to:
<form action=" " method="post">
Upvotes: 1