如何在简单页面上提交表单后获取变量值?

问题描述 投票:0回答:1
==
function onCheck()
{
   // It's simple page, not component, partial or controller
   // Therefore this syntax is right (according October docs)
   $this['myvar'] = "Hello";
}
==

<form class="dates" action="" method="POST" data-request="onCheck">
    <input type='text' class='date_inout' name="start" id='start'>
    <input type='text' class='date_inout' name="end" id='end'>
    <input type="submit" value="Подобрать">
</form>

<h1>{{ myvar }}</h1>

qazxsw poi没有输出。我需要在表单提交后才能获得qazxsw poi,而不是myvarmyvar

先感谢您!

octobercms
1个回答
0
投票

你需要在ajax之后输出然后你需要这样做

onStart

现在,当你点击onInit它将转到== function onCheck() { $dates = post('start') . ' - ' . post('end'); return ['#myvarContsiner' => "Hello " . $dates]; // ^ this id } == <form class="dates" action="" method="POST" data-request="onCheck"> <input type='text' class='date_inout' name="start" id='start'> <input type='text' class='date_inout' name="end" id='end'> <input type="submit" value="Подобрать"> </form> <h1 id="myvarContsiner"></h1> <!-- this id ^ --> 并返回值submit button所以基本上onCheck将根据匹配ID在['#myvarContsiner' => "Hello " . $dates]更新。

当你从"Hello " . $dates返回它时,你的意志会显示出来

如果您有任何疑问请发表评论。

© www.soinside.com 2019 - 2024. All rights reserved.