Есть конкурс интернет голосование.
HTML код:
<form id="polls_form_4" class="wp-polls-form" action="/index.php" method="post">
<li><input type="checkbox" id="poll-answer-71" name="poll_4" value="71" /> <label for="poll-answer-71">1231</label></li>
<input type="button" name="vote" value=" Передать " /></p>
</form>
Требуется сделать URL ссылки так чтобы при переходе по ней автоматически происходило голосование за выбранный объект!
В помощь посмотрите еще код
var poll_id=0,poll_answer_id="",is_being_voted=!1;pollsL10n.show_loading=parseInt(pollsL10n.sh ow_loading);pollsL10n.show_fading=parseInt(pollsL10n.show_fading);
function poll_vote(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_be ing_voted(!0),poll_id=b,poll_answer_id="",poll_multiple_ans_count=poll_multiple_ans=0,a(" #poll_multiple_ans_"+poll_id).length&&(poll_multiple_ans=parseInt(a("#poll_multiple_an s_"+poll_id).val())),a("#polls_form_"+poll_id+" input:checkbox, #polls_form_"+poll_id+" input:radio, #polls_form_"+poll_id+" option").each(function(b){if(a(this).is(":checked")||a(this).is(":selected" ))0<poll_multiple_ans?
(poll_answer_id=a(this).val()+","+poll_answer_id,poll_multiple_ans_count++):poll_answer_id =parseInt(a(this).val())}),0<poll_multiple_ans?0<poll_multiple_ans_count&&poll_multiple_ans_co unt<=poll_multiple_ans?(poll_answer_id=poll_answer_id.substring(0,poll_answer_id.length-1),poll_p rocess()):0==poll_multiple_ans_count?(set_is_being_voted(!1),alert(pollsL10n.text_valid)):(set_is_be ing_voted(!1),alert(pollsL10n.text_multiple+" "+poll_multiple_ans)):0<poll_answer_id?poll_process():(set_is_being_voted(!1),
alert(pollsL10n.text_valid)))})}function poll_process(){jQuery(document).ready(function(b){poll_nonce=b("#poll_"+poll_id+"_non ce").val();pollsL10n.show_fading&&b("#polls-"+poll_id).fadeTo("def",0);poll sL10n.show_loading&&b("#polls-"+poll_id+"-loading").show();b.ajax({type:"PO ST",xhrFields:{withCredentials:!0},url:pollsL10n.ajax_url,data:"action=polls&view=process& poll_id="+poll_id+"&poll_"+poll_id+"="+poll_answer_id+"&poll_"+po ll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success})})}
function poll_result(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_ being_voted(!0),poll_id=b,poll_nonce=a("#poll_"+poll_id+"_nonce").val(),pollsL10 n.show_fading&&a("#polls-"+poll_id).fadeTo("def",0),pollsL10n.show_loading&&a(" #polls-"+poll_id+"-loading").show(),a.ajax({type:"POST",xhrFields:{with Credentials:!0},url:pollsL10n.ajax_url,data:"action=polls&view=result&poll_id="+poll_id+" &poll_"+poll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success}))})}
function poll_booth(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_b eing_voted(!0),poll_id=b,poll_nonce=a("#poll_"+poll_id+"_nonce").val(),pollsL10n .show_fading&&a("#polls-"+poll_id).fadeTo("def",0),pollsL10n.show_loading&&a(" #polls-"+poll_id+"-loading").show(),a.ajax({type:"POST",xhrFields:{withC redentials:!0},url:pollsL10n.ajax_url,data:"action=polls&view=booth&poll_id="+poll_id+" &poll_"+poll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success}))})}
function poll_process_success(b){jQuery(document).ready(function(a){a("#polls-"+poll_id).replaceWit h(b);pollsL10n.show_loading&&a("#polls-"+poll_id+"-loading").hide();pollsL10n.sh ow_fading&&a("#polls-"+poll_id).fadeTo("def",1);set_is_being_voted(!1)})}functio n set_is_being_voted(b){is_being_voted=b};
Разделы:
Опубликован:
11.02.2018 | 20:14 [последние изменения: 11.02.2018 | 20:21]