javascript - How to insert the value of dynamically radio button using PHP? -
i have html table, each table row have radio button dynamically generated. each option in radio button have unique id generated dynamically also. id not yet save in database.
how insert option id? , how update option answer in option id? please me. tried insert values have no luck
scenario:
there's default value radio button, "no". when user change default value, there's confirmation box ask user if he/she want processed. if user click "ok" default value change "yes".
php html table:
echo '<td id="resumefile'.$optionid.'">' . $record_s->attachment_resume_id . '</td>'; echo '<td id="processedyes><label for="yes">yes</label> <input type="radio" id="processedoptionyes'.$optionid.'" name="processedoption" value="yes" onclick="proccessedcheck('.$optionid.',\'yes\')"/> <label for="no">no</label> <input type="radio" id="processedoptionno'.$optionid.'" name="processedoption" value="no" checked="checked" onclick="proccessedcheck('.$optionid.',\'no\')" echo $record_s->process_resume === "no" checked="checked"/>/>no</td>'; echo '</tr>'; } echo '</table>'; } if (isset($_post['optionid']) && $_post['optionid']){ $optionid = $_post['optionid']; $queryoptionid = $wpdb->query("insert resume_databank(process_resume_id) values ('$optionid')"); }
hidden form:
<form id='hiddenform' method='post' action=''> <input type="hidden" id="inputhidden1" name="optionid" /> <input type="hidden" id="inputhidden2" name="optionanswer" /> </form>
js:
function proccessedcheck(optionid,optionanswer){ if(optionanswer == 'yes'){ if (confirm('you have chosen ' + optionanswer + ', correct?')){ jquery("#processedoptionyes" + optionid).attr('disabled',true); jquery("#processedoptionno" + optionid).attr('disabled',true); var withlink = jquery("#resumefile"+ optionid).html(); var withoutlink = jquery(withlink).html(); jquery("#resumefile"+optionid).html("").append(withoutlink); jquery("#inputhidden1").val(optionid); jquery("#inputhidden2").val(optionanswer); jquery("#hiddenform").submit(); } } }
hi u can change jquery using below using class instead of function in input type, add class radiods input type= radio.
$(".radiods").click(function(){ var clickid = this.id; if($('input:radio[name=processedoption]:checked').val() == "yes") { if (confirm('you have chosen yes, correct?')) { $("#inputhidden1").val(clickid); $("#inputhidden2").val("yes"); } } });
and use ajax update in database,so no need of form
Comments
Post a Comment