Passing Jquery value to PHP form -


i have simple form in php page:

<form role="form" method="post" action="send-message.php">     <input type="text" id="sendto" name="sendto" value="">     <textarea class="form-control text-input" name="message"></textarea>     <button type="submit" class="btn btn-primary">send</button> </form> 

the value of sendto input set jquery script same page:

$("button").click(function() {     $("#sendto").val($(this).siblings('.username').val()); }); 

then have php script in send-message.php:

<?php $message = $_post["message"]; $sendto = $_post["sendto"];  echo $sendto; //nothing here! 

now, why value of sendto not passing form send-message.php?

it's weird because in form, can see value of input it's not passed send-message.php.

i tried method , it's same thing...

thank help!

the missing code:

<?php foreach($mostcompatibleusers $otheruser => $score): ?> <?php  $compatibilityscore = getcompatibilityscore($score, $maxscore); ?>     <div class='col-sm-4 col-xs-6'>         <div class='box-info full'>             <div class='img-wrap'>             <img src='images/default-profile-pic.png' alt='image small'>         </div>         <div class='des-thumbnail'>             <h4><b><?php echo $otheruser; ?></b> <small>niveau de compatibilité: <b><?php echo $compatibilityscore; ?>%</b></small></h4>             <div class='progress progress-striped active'>                 <div class='progress-bar progress-bar-success' role='progressbar' aria-valuenow='<?php echo $compatibilityscore; ?>' aria-valuemin='0' aria-valuemax='100' style='width: <?php echo $compatibilityscore; ?>%'></div>             </div>             <div class='row'>                 <div class='col-md-6'>                     <input type="hidden" class='username' value="<?php echo $otheruser;?>">                      <button type='button' class='btn btn-success btn-sm btn-block' data-toggle='modal' data-target='#mymodal'><i class='fa fa-envelope'></i> send message</button>                 </div>             </div>         </div>     </div> </div> <?php endforeach; ?> 

more details can see last added code, there foreach loop display users information , button allow send message particular user.

when press button send message, pops out modal window containing form can write , send message. it's not regular architecture! think not simplifying situation..

there no .username class in code.

by calling $(this).siblings('.username') getting other elements of form $(this) submit button.

providing more code useful. .username class is.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -