php - how to show textbox if radio button value is checked from database? -
i have 3 radio buttons
<input type="radio" name="preferedpaymt" value="checkmailed" id="checkmailed1" <?php if($paymnt=="checkmail") {?> checked="checked" <?php }?> /> (a)check mailed <input type="radio" name="preferedpaymt" value="paypal" <?php if($paymnt=="paypal") {?> checked="checked" <?php }?> /> (b)by paypal <input type="radio" name="preferedpaymt" value="wiretransfer" id="wiretransfer" <?php if($paymnt=="wiretransfer") {?> checked="checked" <?php }?> /> (c)wire transfer bank a/c$12
but value of radiobutton checked database . these 2 tables associated if radiobutton 2 checked table1 1 should populate id tb1
here problem when value of radio button checked database table not populate if click gets populated want automatis how can it?
jquery code, using
<script type="text/javascript"> jquery(function () { jquery("input[name=preferedpaymt]").change(function () { if ($(this).val() == "paypal") { jquery("#ppl").slidedown() } else { jquery("#ppl").slideup(); } }); }); </script>
or culd use:
var chk_val = jquery("input[name='preferedpaymt']:checked").val(); alert(chk_val);
edit: how use it!
your inputs:
<input type="radio" name="preferedpaymt" value="checkmailed" id="checkmailed1" <?php if($paymnt=="checkmail") {?> checked="checked" <?php }?> /> (a)check mailed <input type="radio" name="preferedpaymt" value="paypal" <?php if($paymnt=="paypal") {?> checked="checked" <?php }?> /> (b)by paypal <input type="radio" name="preferedpaymt" value="wiretransfer" id="wiretransfer" <?php if($paymnt=="wiretransfer") {?> checked="checked" <?php }?> /> (c)wire transfer bank a/c$12
then lets got 1 tables each payment choise. ex:
note tables has same classname because want hide of them default. id attribute set "table_paymentmethod".
<table class="payment_table" id="table_checkmailed" height="200" bgcolor="#00ff33" width="100px;" > <tr> <td> checked checked mail </td> </tr> </table> <table class="payment_table" id="table_paypal" height="200" bgcolor="#ff0000" width="100px;" > <tr> <td> checked paypal </td> </tr> </table> <table class="payment_table" id="table_wiretransfer" height="200" bgcolor="#ccc" width="100px;" > <tr> <td> checked wiretransfer </td> </tr> </table>
now part jquery comes in handy.
<script type="text/javascript"> jquery(document).ready(function(){ jquery('.payment_table').hide(); // hide tables default var chk_val = jquery("input[name='preferedpaymt']:checked").val(); // grab value of selected radio jquery('#table_'+chk_val).slidedown(1000); // slides down right table on page load. }); </script>
well there go, should trick you. im not best @ explaining should pretty straightforward.
Comments
Post a Comment