-1
header.tpl(within /templetes)

---------------------------------------------
<HTML>
<HEAD>
<TITLE>{$title}</TITLE>
{literal}
<style type="text/css">
body{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
color:#333333;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
  <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<style type="text/css">
* { font-family: Verdana; font-size: 96%; }
label { width: 10em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
p { clear: both; }
.submit { margin-left: 12em; }
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
</style>


  <script type="text/javascript" language="javascript">
  $(document).ready(function(){
    $("#commentForm").validate();
                                 });

  function ajaxFunction(){
 var ajaxRequest;  // The variable that makes Ajax possible!

 try{
   // Opera 8.0+, Firefox, Safari
   ajaxRequest = new XMLHttpRequest();
 }catch (e){
   // Internet Explorer Browsers
   try{
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
   }catch (e) {
      try{
         ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
      }catch (e){
         // Something went wrong
         //alert("Your browser broke!");
         return false;
      }
   }
 }
 // Create a function that will receive data 
 // sent from the server and will update
 // div section in the same page.
 ajaxRequest.onreadystatechange = function(){
   if(ajaxRequest.readyState == 4){
      var ajaxDisplay = document.getElementById('ajaxDiv');
      ajaxDisplay.value = ajaxRequest.responseText;
   }
 }
 // Now get the value from user and pass it to
 // server script.
 var cname = document.getElementById('cname').value;
 var lname = document.getElementById('lname').value;
 var date = document.getElementById('date').value;

 var queryString = "?cname=" + cname ;
 queryString +=  "&lname=" + lname + "&date=" + date;

ajaxRequest.onreadystatechange=stateChanged;
ajaxRequest.open("POST","demo/process.php?cname="+cname+"&lname="+lname+"&date="+date,true);
ajaxRequest.send(null); 

}


  </script>

{/literal}
</HEAD>
<BODY >

index.tpl 如下

{include file="header.tpl" title= $title }
<h1>Login Form</h1>
<form class="cmxform" id="commentForm" >
 <fieldset>

   <p>
     <label for="cname"> First Name</label>
     <em>*</em><input id="cname" name="cname" size="25" class="required" minlength="2" />
   </p>
   <p>
     <label for="lname">Last Name</label>
     <em>*</em><input id="lname" name="lname" size="25"  class="required" />
   </p>
   <p>
     <label for="Date">Date</label>
     <em>*</em><input id="date" name="date" size="25"  class="required" value="" />
   </p>

   <p>
   <input class="submit" type="submit" value="Submit" class="button" onclick='ajaxFunction()' />
   </p>
 </fieldset>
 </form>

现在我想在 process.php 中获取 cname、lname、date。不幸的是我没有得到它我尝试了很多

当我在 index.php 中完成时,我没有得到任何值,请指导我............

4

1 回答 1

0

您是否尝试过使用$smarty->get_template_vars() (Smarty2) 或$smarty->getTemplateVars() (Smarty3) 来获取值?

于 2012-07-04T08:18:52.550 回答