Grab Value from Javascript popup - use as php post value -
first off, if there better way of doing this? let me know... way seems kind of "hackish". here trying do: see in below input
, have text field simple want appear <a>
link. if user clicks it, want javascript
pop box appear user entering email. want them hit ok, , send email value form , form submits via php post.
i not know how grab value box , insert in form
(if possible) can submit php
.
here code:
<form id="frm1" action="login.php" method = "post"> <input onclick="resetpassword()" type="text" name="email" value="reset password" style="cursor: pointer; background:none; text-decoration: underline; border: none;" /> </form> <script> function resetpassword() { var x; var email=prompt("enter email reset password.", "example@email.com"); if (email!=null) { document.getelementbyid("frm1").submit(); } } </script> <?php if (isset($_post['email'])) { $email = $database -> escape_value(trim($_post['email'])); // reset password } ?>
grab email promt, paste input field , submit form.
<form id="frm1" action="login.php" method='post'> <input id="email" onclick="resetpassword()" type="text" name="email" placeholder="reset password" /> </form> <script type="text/javascript"> function resetpassword() { var email = prompt("enter email reset password.", "email@example.com"); if (email != null) { document.getelementbyid("email").value = email; document.getelementbyid("frm1").submit(); } } </script>
Comments
Post a Comment