doumi1884 2015-03-09 09:57
浏览 64

JavaScript和PHP中的数据提交

I have a set button before the user submits a registration, where I need to set html before the server submits the php code. However, I cannot seem to get this working, any suggestions? I;am using typeahead.js for the input. (Full Name works perfectly)

<div class="col-md-6 col-sm-12 col-xs-12">
   <div>
 <?php $full_name = 'akID[' . UserAttributeKey::getByHandle('full_name')->getAttributeKeyID() . '][value]'; ?>
        <?php echo $form->label($full_name, t('Full Name')); ?>
        <?php echo $form->text($full_name); ?>
   </div>
   <br/>
<form id="school" onclick="doThis()">
<?php $school = 'akID[' . UserAttributeKey::getByHandle('school')->getAttributeKeyID() . '][value]; ?>]'; ?>
   <?php echo $form->label($school, t('Please Select your School from the Dropdown Box.') )?><br/>
    <input type=text id="school" name="school" class="form-control typeahead" value="Enter Your School ">
      <input type="button" value="Set" onsubmit="setSchool();"/>
</form>


<script>
function setSchool()
{
 var school = $("#school").val();
 $school = $_POST(school);
}
</script>


</div>
</form>
  • 写回答

1条回答 默认 最新

  • dp709369831 2015-03-09 10:04
    关注

    You cannot have the same id for form and input. Change or remove id attribute from school input, add method='post' to the form and change your function setSchool to:

    function setSchool()
    $('input[name="school"]).val("<?php echo json_encode($_POST["school"]); ?>");
     $("#school").submit();
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog