dongxue7306 2009-07-17 10:19
浏览 38
已采纳

如何在XMLHttpRequest之后调用nicEdit(editbox)或jquery(文本框的datepicker)?

Need help (or an example) as I don't seems to be able to invoke jquery datepick or nicEdit when using XMLHttpRequest.

My code comes with 4 php files:

<p>Main page:&nbsp;main.php<br />
  ++++++++++++++++++<br />
  &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
  &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
  &lt;head&gt;<br />
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;<br />
  &lt;title&gt;Education Centre&lt;/title&gt;<br />
  &lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;<br />
  &lt;script type=&quot;text/javascript&quot; src=&quot;script.js&quot;&gt;&lt;/script&gt;<br />
  &lt;script type=&quot;text/javascript&quot; src=&quot;mainjs.js&quot;&gt;&lt;/script&gt;<br />
  &lt;script src=&quot;http://js.nicedit.com/nicEdit-latest.js&quot; type='text/javascript'&gt;&lt;/script&gt;<br />
  &lt;script type=&quot;text/javascript&quot;&gt;bkLib.onDomLoaded(nicEditors.allTextAreas);&lt;/script&gt;</p>
<p>&lt;/head&gt;<br />
  &lt;body onLoad=&quot;init_table();&quot;&gt;<br />
  &lt;div id=&quot;page&quot;&gt;<br />
  &lt;form name='form1'&gt;<br />
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
  &lt;div id=&quot;content&quot;&gt;<br />
  &lt;div id=&quot;showTable&quot;&gt;        &lt;/div&gt;<br />
  &lt;/div&gt;<br />
  &lt;/form&gt;<br />
  &lt;/div&gt;<br />
  &lt;!-- end page --&gt;<br />
  &lt;/body&gt;<br />
  &lt;/html&gt;<br />
</p>
<br />


<p>mainjs.js<br />
  +++++++++<br />
  function init_table() {<br />
  requestInfo('showMain.php?mode=list&amp;prev_cid=1','showTable','');<br />
  }</p>
<p>&nbsp;</p>
<p>script.js [copied and tested to be ok with other pages]<br />
  +++++++++++++++++++++++++++++++++++++++++++++++++++++++<br />
  function getHTTPObject() {<br />
  var xmlhttp;<br />
  <br />
  if(window.XMLHttpRequest){<br />
  xmlhttp = new XMLHttpRequest();<br />
  }<br />
  else if (window.ActiveXObject){<br />
  xmlhttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);<br />
  if (!xmlhttp){<br />
  xmlhttp=new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);<br />
  }<br />
  <br />
  }<br />
  return xmlhttp;<br />
  }</p>
<p>var http = getHTTPObject(); // We create the HTTP Object</p>
<p>function requestInfo(url,id,redirectPage) { <br />
  var temp=new Array();<br />
  http.open(&quot;GET&quot;, url, true);<br />
  http.onreadystatechange = function() {<br />
  if (http.readyState == 4) {<br />
  if(http.status==200) {<br />
  var results=http.responseText;<br />
  if(redirectPage==&quot;&quot; || results!=&quot;1&quot;) {<br />
  var temp=id.split(&quot;~&quot;); // To display on multiple div <br />
  var r=results.split(&quot;~&quot;); // To display multiple data into the div <br />
  if(temp.length&gt;1) {<br />
  for(i=0;i&lt;temp.length;i++) { <br />
  document.getElementById(temp[i]).innerHTML=r[i];<br />
  }<br />
  } else {<br />
  document.getElementById(id).innerHTML = results;<br />
  } <br />
  <br />
  } else {<br />
  window.location.href=redirectPage; <br />
  }<br />
  } <br />
  }<br />
  };<br />
  http.send(null);<br />
  }<br />
</p>

<br />
<p>showMain.php<br />
  ++++++++++++<br />
  &lt;?php<br />
header('Content-Type: text/xml');</p>
<p>//include(&quot;config.php&quot;);<br />
  //include(&quot;mysql.lib.php&quot;);<br />
  //$obj=new connect;<br />
  <br />
  $netwkinfo = &quot;Some information pulled from database&quot;;<br />
  echo &quot;&lt;table&gt;&quot;;<br />
  echo &quot;&lt;tr&gt;&lt;td&gt;My Data&lt;/td&gt; &lt;td&gt;&lt;textarea id='netwkinfo' cols='75' rows='5' &gt;&quot; . $netwkinfo . &quot;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;&quot;;<br />
  echo &quot;&lt;/tr&gt;&quot;;<br />
  echo &quot;&lt;/table&gt;&quot;;<br />
  ?&gt;<br />
</p>

showMain.php is a file that extract data from a database to be displayed/edited etc... but for simplicity i assign a value to $netwkinfo.

What I will like to see is nicEdit feature (panel) shown at the editbox. Unfortunately I am not seeing it, just a plain edit box appears. What could be wrong and how should i correct it for it to work.

Similarly IF I used jquery datepicker on a textbox in the showmain.php, i am not seeing it work too. I think its the same concept but just couldn't figure out how to get them working.

Appreciate any help here. Thanks.

  • 写回答

2条回答 默认 最新

  • duanmeng2842 2009-07-19 14:30
    关注

    Found the hint to the answer here.

    have not successfully implement nicedit yet but datepicker for jquery was resolved.

    for datepicker I used:

    $(function(){
      $('.inputDate').live('click', function() {
        $(this).datepicker({
          starts: 1,
          position: 'right',
          onChange: function(formated, dates){
            $('#inputDate').val(formated);
            $('#inputDate').DatePickerHide();
          }
        });
      });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 数学的三元一次方程求解
  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题