后台
function 指定的模板名称(){
$this->updates('users');
}
function upmyInfo(){
$this->doSV('users');
}
封装的函数
/**
+----------------------------------------------------------
* updates指定表修改函数
+----------------------------------------------------------
* @var array
* @access public
+----------------------------------------------------------
*/
function updates($surface){
//实例化模型$surface为自己指定的表名
$content=D($surface);
//接收待修改信息的id,需要从自己点击修改的数据的id通过地址栏传过来id
//$id=$_GET['id'];
$list=$content->find($_SESSION['user_id']);
//填充数据执行修改前台接收{$content}为指定的数据的id对应的所有的数据
$this->assign("content",$list);
}
/**
+----------------------------------------------------------
*doSV修改后的数据提交到指定数据表的函数
+----------------------------------------------------------
* @var array
* @access public
+----------------------------------------------------------
*/
function doSV($surfac){
//echo $surfac;
$content=D($surfac);
if($content->create()){
//执行插入操作,执行成功后,返回新插入的数据库的id
if($content->save()){
$this->success("修改成功!",__URL__."/member_guanli?id=".$_SESSION['user_id']);
}else{
$this->error("修改失败!");
}
}else{
//把错误信息提示给用户看
$this->error($content->getError());
}
}
前台
<script type="text/javascript" src="__PUBLIC__/js/upssx.js"></script>
<script language="javascript" type="text/javascript">
function convert(){
var obj = document.getElementById('s1'); //定位id
var index = obj.selectedIndex; // 选中索引
var text = obj.options[index].text; // 选中文本
var obj2 = document.getElementById('s2'); //定位id
var index2 = obj2.selectedIndex; // 选中索引
var text2 = obj2.options[index2].text; // 选中文本
var obj5 = document.getElementById('s3'); //定位id
var index5 = obj5.selectedIndex; // 选中索引
var text5 = obj5.options[index5].text; // 选中文本
var text3=text+"省"+text2+"市"+" "+text5;
//alert(text3);
var text4=text;
document.getElementById('PrCi').value=text3;
document.getElementById('PrCi2').value=text4;
document.getElementById('PrCix').value=text3;
document.getElementById('PrCiu').value=text3;
}
function value(){
document.getElementById('values').focus();
}
</script>
<form name="form1" action="__URL__/upmyInfo" method="post">
<table width="614" height="365" border="0" cellpadding="0" cellspacing="0" id="guanli_biaodan">
<tr>
<td width="110" rowspan="2"><img src="__PUBLIC__/img/member_13.jpg"/></td>
<td width="91" align="center" >名称:</td>
<td width="402" ><input class="guanli_text" type="text" value="{$content.users_name}" name="users_name"/><input type="hidden" name="users_id" value="<php>echo $_SESSION['user_id']</php>"/></td>
</tr>
<tr>
<td height="88" align="center">性别:</td>
<td>
<if condition="$content.users_sex eq '0'">
<label>
<input type="radio" name="users_sex" value="0" checked="checked"/>
男</label>
<label>
<input type="radio" name="users_sex" value="1" />
女</label>
<elseif condition="$content.users_sex eq '1'"/>
<label>
<input type="radio" name="users_sex" value="0" />
男</label>
<label>
<input type="radio" name="users_sex" value="1" checked="checked" />
女</label>
</if>
</td>
</tr>
<tr>
<td height="54" align="right">所在地区:</td>
<td colspan="2">
<input type="hidden" name="PrCi" id="PrCi"/>
<input type="hidden" name="PrCi2" id="PrCi2"/>
<input type="hidden" name="address" id="PrCix"/>
<input type="hidden" name="users_address" id="PrCiu"/>
<select class="guanli_select" name="s1" id="s1">
<option value="-选择省份-" >-选择省份-</option>
</select>
<select class="guanli_select" name="select" id="s2">
<option value="-选择市-" >-选择省市-</option>
</select>
<select style="display:none;" id="s3" >
<option value="">市,县级市</option>
</select>
<script type="text/javascript" src="__PUBLIC__/js/downssx.js"></script>
</td>
</tr>
<tr>
<td align="right">联系电话:</td>
<td colspan="2"><input class="guanli_text" name="users_tel" type="text" value="{$content.users_moblie}"/></td>
</tr>
<tr>
<td align="right">手机:</td>
<td colspan="2"><input class="guanli_text" name="users_moblie" type="text" value="{$content.users_moblie}"/></td>
</tr>
<tr>
<td align="right">邮箱:</td>
<td colspan="2"><input class="guanli_text" name="user_email" type="text" value="{$content.user_email}"/></td>
</tr>
<tr>
<td> </td>
<td><input class="guanli_btn" type="submit" value="确认提交"/></td>
<td> </td>
</tr>
</table>
</form>
更多详细信息请查看 java教程网 http://www.itchm.com/forum-59-1.html