jquery - 用php和ajax无刷新添加radio button并保存其选中的状态
阿神
阿神 2017-04-10 15:51:11
[PHP讨论组]

点击第一张图的add按钮,会生成一个新的表格,并会保存其选中的单选框状态,但是再点击的话因为生成的单选框name属性一样,选中的状态会被顶掉
$id = mysql_insert_id();
$head = "

"; $foot = "

";
if($formate=='standard 85x55mm'){
$result = "

Formate:
<input name='formate' type='radio' value='standard 85x55mm' checked>standard 85x55mm
";
}else{
$result = " Formate:<input name='formate' type='radio' value='standard 85x55mm'>standard 85x55mm
";
}
if($formate=='carte double 170x55mm'){
$result.="<input name='formate' type='radio' value='carte double 170x55mm' checked>carte double 170x55mm";
}else{
$result.="<input name='formate' type='radio' value='carte double 170x55mm'>carte double 170x55mm";
}
if($papier=='350g couche mat'){
            $result.="<td><input name='papier' type='radio' value='350g couche mat' checked>350g couche mat<br/>";
        }else{
            $result.="<td><input name='papier' type='radio' value='350g couche mat' >350g couche mat<br/>";
        }
        if($papier=='300g offset'){
            $result.="<input name='papier' type='radio' value='300g offset' checked>300g offset</td>";
        }else{
            $result.="<input name='papier' type='radio' value='300g offset' >300g offset</td>";

        }
        if($imprimer=='Recto seule'){
            $result.="<td><input name='imprimer'  type='radio' value='Recto seule' checked>Recto seule<br/>";
        }else{
            $result.="<td><input name='imprimer' type='radio' value='Recto seule' >Recto seule<br/>";
        }
        if($imprimer=='Recto et verso'){
            $result.="<input name='imprimer' value='Recto et verso' type='radio' checked>Recto et verso</td>";
        }else{
            $result.="<input name='imprimer' value='Recto et verso' type='radio'>Recto et verso</td>";
        }
        if($pelliculage=='Recto seule brillant'){
            $result.= "<td><input name='pelliculage' value='Recto seule brillant' type='radio' checked>Recto seule brillant<br>";
        }else{
            $result.= "<td><input name='pelliculage' value='Recto seule brillant' type='radio' >Recto seule brillant<br>";
        }
        if($pelliculage=='Recto seule mat'){
            $result.="<input name='pelliculage' value='Recto seule mat' type='radio' checked>Recto seule mat<br/>";
        }else{
            $result.="<input name='pelliculage' value='Recto seule mat' type='radio' >Recto seule mat<br/>";
        }
        if($pelliculage=='Recto et verso brillant'){
            $result.="<input name='pelliculage' value='Recto et verso brillant' type='radio'>Recto et verso brillant<br/>";
        }else{
            $result.="<input name='pelliculage' value='Recto et verso brillant' type='radio'>Recto et verso brillant<br/>";
        }
        if($pelliculage=='Recto et verso mat'){
            $result.="<input name='pelliculage' value='Recto et verso mat' type='radio' checked>Recto et verso mat<br/>";
        }
        else{
            $result.="<input name='pelliculage' value='Recto et verso mat' type='radio' >Recto et verso mat<br/></table>";
        }
        $result.="<table><thead><th>Id</th><th>count</th><th>price</th><th>price2</th><th>price3</th></thead><tbody><td>1</td><td><input name='count' type='text'></td><td><input type='text' name='price1'></td><td><input type='text' name='price2'></td><td><input type='text' name='price3'></td><td><button>add</button></td></tbody></table>";
        echo $head.$result.$foot;


阿神
阿神

闭关修行中......

全部回复(1)
高洛峰

为啥不生成name不一样的?

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号