php - JavaScript parsing value -
while clicking submit button of following form,
<form id="message-form" action="#" method="post"> <div class="text-middle"> <?php foreach($result $row) { ?> <button class="button button1" value="<?php echo $row['id']; ?>" onclick="myfunction(this)"><?php echo $row['id']; ?></button> <?php } ?> </div> </form>
the value
sent function
window.onload = function() { var messagefield = document.getelementbyid('message'); var messageslist = document.getelementbyid('messages'); var form = document.getelementbyid('message-form'); var message = messagefield.value; }
but showing same value every click
the "window.onload" function fires @ end of document loading process. @ point, of objects in document in dom, , images, scripts, links , sub-frames have finished loading. reason getting same values.
i think have call myfunction , not window.onload.
Comments
Post a Comment