简体   繁体   中英

How to enable a disabled text input field from one page to another

I'm am developing a project in php but my java is not good. I am trying to link two pages. The first page has a buttons including "Other" for donations which should work in a way that a user should click the button be redirected to the next page where the input text field for the amount should not be disabled.

I hope you are able to assist me because i read almost every post here about onclick events and other options and tried them but to no luck.

 //Code for the other button <td style="padding: 6px;"> <span> <form action="getcreditcard.php" method="POST"> <input type="hidden" value="<?php echo base64_encode(6); ?>" name="id"> <button type="submit" id="donate" value="Other" class="btn btn-warning" style="width: 100%;">Other</button> </form> </span> </td> //Code for the receiveing page getcreditcard.php < } else if (base64_decode($_POST['id']) == 6) { $p_price ='Add Amount Here.'; $p_currency = 'USD'; $p_name = 'Donation Option 5'; } > and <div class="form-row"> <label> <span>Amount (USD)</span> <input type="text" name="amount"placeholder="enter amount " value="$ <?php echo $p_price; ?>" disabled="true" required="true"> </label> </div> 

Use the javascript jquery prop() like this:

<!-- simple example: -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<form>
Input:
<input type="text" name="amount" id="amount" placeholder="enter amount " value="$ <?php echo $p_price; ?>" required>
</form>

<script type="text/javascript">
        $(document).ready(function(){
             $("#amount").prop("disabled", true);
        });
</script>

您可以使用只读吗,希望对您有所帮助。

<input type="text" readonly value="<?php echo base64_encode(6); ?>" name="id">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM