php - How to post textbox value after selecting particular checkbox -
here snippet of html code.....
1)after checking each check box value's posting database.
2)but problem when checked other, need take value of text box , posting value of checkbox instead of textbox value
but don't know did mistake...
<form action="purchase.php" name="form1" id="form1" method="post"> <ul class="n_ul"> <span>*</span> primary goal? <br> <br> <li> <input name="goal" id="goal" value="add popular customer service attract/retain more customers" type="checkbox"> </li> <span>*</span> popular customer services <br> <br> <li> <input name="goal" id="goal" value="add turnkey revenue sources location(s)" type="checkbox"> </li> <span>*</span> trunkey revenue source <br> <br> <li> <input name="goal" id="goal" type="checkbox" value="other"> </li> <span>*</span> other (please specify below) <br> <br> <input name="other" id="goal" type="text" class="new"> </ul> <input type="submit" name=submit value="submit"> </form>
any suggestions acceptable....
try like
$_post['goal'] = ($_post['goal']=='other') ? $_post['other'] : $_post['goal'];
this overwrite value of goal value of other when 'other' radio ticked
also id attributes of html elements should unique on page
edit
your question little vague. seems may want form submit when checkbox button clicked.
- if case other field unlikely filled form submitted before user gets populate it
- try adding button or input submit form
like this
<button type="submit">submit</button>
Comments
Post a Comment