ホームページ  >  記事  >  バックエンド開発  >  PHP形式で判定を解く方法

PHP形式で判定を解く方法

WBOY
WBOYオリジナル
2016-06-13 13:51:56850ブラウズ

PHP形式での判定
{{foreach from=$selectAry item=select}}
{{if $select.id == sid}}
{{$select.name}}
{{ /if}}
{{/foreach}}
ここで周期的に出力していますが、私のフォームに対応する ID を出力してもらいました。これは今の私の判断です。 1つ入力可能
判定を外すと2つ出力

PHPコード
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--> <form name="favForm" id="favForm" action="javascript:void(0)" method="POST">
                    <input type="hidden" id="hidden_sid" name="part[sid]" value="">
                    <input type="hidden" id="hidden_uid" name="part[uid]" value="{{$uid}}">
                    <p bgcolor="blue" style="margin-top:30px;">
                    
                         {{foreach from=$selectAry item=select}}    
                         {{if $select.id == sid}}                    
                           {{$select.name}}
                           {{/if}}
                          {{/foreach}}
                            
                     <input type="radio" id="is_good_1"  name="part[is_good]" value="1"><img src="http://static.h-elab.com/img/xiao.gif"><input type="radio" id="is_good_2" name="part[is_good]" value="0"><img src="http://static.h-elab.com/img/ku.gif">
                    </p>
                    <div id="isPlist" style="margin-top:4px;">
                        <p><textarea id='part_text' name="part[text]"  cols="28" rows="4" style="padding:3px;font-size:15px;LINE-HEIGHT:18px; height:90px;" onclick="clien();">输入您的看法,字数在50字内</textarea></p>
                    </div>
                    <p>
                        <input type="button" id="favButton" value="确 定" class="pop_but" onclick="sendData();showDiv();">
                        <input type="reset" id="button" value="取 消" class="pop_but" onclick="showDiv();" style="margin-left:40px;">
                    </p>
                </form>



JScriptコード
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
function sendData(){
    var uid=document.getElementById('hidden_uid').value;
    var sid = document.getElementById('hidden_sid').value;
    var text = document.getElementById('part_text').value;
    var rideo = document.getElementsByName('part[is_good]');
    var is_good;
    if(text == '' || text == '输入您的看法,字数在50字内'){
        alert('请提出您的看法,不然投票无效哦!');
        return false;
    }
    alert (sid);
    for(var i=0; i<rideo.length;i++){
        if(rideo[i].checked == true){
            is_good = rideo[i].value;
        }
    }
    var url = 'http://www.h-elab.com/ajax/part/recode.php';
    $.getJSON(url,{uid:uid,sid:sid,text:encodeURIComponent(text),is_good:is_good},function(data){
        return true;
    });

}




------解決策---------
なぜフォームに一意の識別子を与えないのでしょうか?
これは、チームの精神を示していません
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。