RICO学习,innerhtml

30 篇文章 0 订阅
         prototype大家都知道了,是一个优秀的js库,rico也不例外,两者绑定使用效果更强大,具体两者之间的关系,我没有太关注,现在将RICO的innerhtml例子贴出来大家学习,后端使用jsp技术,当然使用asp,php亦可。
inner.html
         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<link href="css/rico.css" media="all" rel="Stylesheet" type="text/css" />
<link href="css/openrico.css" media="all" rel="Stylesheet" type="text/css" />
<link href="css/rico_header.css" media="all" rel="Stylesheet" type="text/css" />
<link href="css/ricoTests.css" media="all" rel="Stylesheet" type="text/css" />
    <head>
        <title>lnner numberOne</title>
        <script src="script/prototype.js"></script>
        <script src="script/rico.js"></script>
    </head>
    <body>

<br>

   <div class="accordionTabContentBox">         
   </div>
  
   <div id="rolodexTabContent" class="accordionTabContentBox">
        <table cellspacing="5" cellpadding="5">
            <tr>
                <td valign="top">
                    <select id="listBox" size="10" οnchange="getPersonInfo(this)" style="font-family:arial;font-size:11px;display:inline;border:1px solid red">
                        <option value="aa">
                            aa
                        </option>
                        <option value="bb">
                            bb
                        </option>
                        <option value="cc">
                            cc
                        </option>
                    </select>
                </td>
                     
                <td>
                    <div class="accordionTabContentBox">         
                       </div>
                    <div class="accordionTabContentBox" id="personInfo">
                        Select a name to the left to see the AJAX rolodex entry for the selected person.
                    </div>
                </td>
               
            </tr>
        </table>
</div>
        <script>
            ajaxEngine.registerRequest('getPersonInfo','getPerson.jsp');
            ajaxEngine.registerAjaxElement('personInfo');
            function getPersonInfo(selectBox){
                var firstName = selectBox.value;
                ajaxEngine.sendRequest('getPersonInfo',
                                       "firstName=" + firstName);
            }
    </script>
    </body>
</html>

getPerson.jsp

<%@ page language="java" import="java.util.*" contentType="text/xml; charset=ISO-8859-1"%>

<% String firstName = request.getParameter("firstName");
        %>

<ajax-response>
<response type="element" id="personInfo">
<div class="person">
    <span class="personName"> <%=firstName%></span><span class="personAddress">1743 1st Avenue Boston,Boston 71204-2345</span><span class="personOccupation">Executive Vice President</span>
    <span calss="personPhoneNuember">
    Phone #: (972) 555-0293</span><span class="personMobile">Mobile #: (972) 555-0295</span><span class="personNotes">Notes: Spouse playes tennis at the country club with John.</span>
</div>
</response>
</ajax-response>

inner.html 中select标签的onChange动作调用 getPersonInfo方法,该方法发送请求到已经注册到RICO提供的引擎种的getPerson.jsp,用于调用服务端JSP页面,出现显示效果,当然innerhtml效果是因为jsp中的
<ajax-response>标签,大家慢慢看吧,我要开始热身了,英格兰 VS  巴拉圭,哈哈...
       对了还要下载rico和  prototype库,和相应的一些CSS文件,css文件只是为了美化布局和美观,可以取掉!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值