我的目的是获取操作 url 表单的输入值。
网址:
<form method="POST" action="/search/the/{{$request->find}}">
{{csrf_field()}}
<div id="check" class="input-group margin-bottom-sm">
<input class="form-control" type="text" name="find" placeholder="Search">
<button type="submit"><div id="search" class="input-group-addon"><i class="fa fa-search"></i></div></button>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
路线:
Route::post('/search/the/{names}', 'maincontroller@search');
Route::get('/tfind', 'maincontroller@takefind');
Run Code Online (Sandbox Code Playgroud)
控制器:
public function search($names, Request $request)
{
//dd($request->find);
$names = $request->input('find');
if(!empty($names)){
$find = DB::table('products')
->select('name', 'description', 'price')
->where('name', 'LIKE', '%' . $names . '%')
->orwhere('description', 'LIKE', '%' . $names . '%')
->orwhere('price', 'LIKE', '%' . $names . '%')
->get();
}
return view('layouts.search', compact('find', 'names'));
}
public function takefind(Request $request) …Run Code Online (Sandbox Code Playgroud) 在控制器中
class acontroller extends Controller
{
private $variable;
public function __construct(){
$this->variable;
}
public function first(){
$calculation = 1 + 1;
$this->variable = $calculation;
return view('something.view');
}
public function second(){
dd($this->variable);
return view('something.view2');
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个例子。我想做的是将第一个方法中的计算结果传递给第二个方法。我期望在 dd() 内的第二个方法中显示结果 2,但我得到的是 null。
出了什么问题以及如何解决这个问题?
HTML:
<form class="allforms" method="POST" action="/auth/myaccount/personal">
<input type="hidden" name="_method" value="PATCH">
...
</form>
<button id="allsubmit" class="btn btn-info">Continue</button>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$(document).ready(function(){
$("#allsubmit").click(function(){
$('.allforms').submit();
});
});
Run Code Online (Sandbox Code Playgroud)
我在上面的html代码中有3个表单.我的按钮不在我的任何表格中.如何为我的所有表单提供一个提交按钮.我尝试了点击功能,但它不起作用.为什么?
var x = 1;
$("#sinolo input").attr('value', x);
$("#inc").click(function(){
$("#sinolo input").attr('value', x++);
});
$("#dec").click(function(){
$("#sinolo input").attr('value', x--);
});Run Code Online (Sandbox Code Playgroud)
#sinolo{
width: 35%;
float: left;
}
#sinolo input{
width: 45%;
border: none;
text-align: center;
}
#sinolo button{
width: 25%;
font-size: 10px;
padding: 8px 0px;
}Run Code Online (Sandbox Code Playgroud)
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div id="sinolo">
<button id="dec" class="btn btn-info fa fa-minus pull-left"></button>
<input type="text" name="" value="">
<button id="inc" class="btn btn-info fa fa-plus pull-right"></button>
</div>Run Code Online (Sandbox Code Playgroud)
你可以看到我面临两个问题.
在我按下按钮的开始时,该过程延迟并通过第二次点击开始计数.
如果我按下+(加号)按钮然后按 - (减号)按钮,则该过程无法正常工作.我能做什么?
我遇到了Wamp的两个问题。
1)我不能升级PHP版本。我尝试了一种推荐的方式https://john-dugan.com/upgrade-php-wamp/,但是没有用。
2)我无法将php版本从5.6.16更改为7.0.0(wamp的默认版本)
当我在wamp服务器中添加Magento框架时,就会出现这些问题。Magento设置可接受的唯一版本是5.6.5、7.0.2、7.0.4、7.0.6
我能做什么?
我想转换json数据并将返回值放入javascript数组中.我使用jquery版本1.9.1
jQuery的:
$('#searchinput').on('keyup', function(){
$value2=$(this).val();
$.ajax({
type: 'get',
url: '{{URL::to('search')}}',
data: {'thesearch':decodeURIComponent($value2)},
success:function(game){
alert(JSON.stringify(game));
}
});
});
Run Code Online (Sandbox Code Playgroud)
结果如下:
[{"name":"First name"},{"name":"Second Name"}]
Run Code Online (Sandbox Code Playgroud)
我想要的是将值存储到javascript数组中,如下所示:
var namearray = ['First name', 'Second Name'];
Run Code Online (Sandbox Code Playgroud)
怎么做?