Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将背景色设置为“从另一刀片中的窗体分割”_Javascript_Php_Html_Laravel_Laravel 5 - Fatal编程技术网

Javascript 将背景色设置为“从另一刀片中的窗体分割”

Javascript 将背景色设置为“从另一刀片中的窗体分割”,javascript,php,html,laravel,laravel-5,Javascript,Php,Html,Laravel,Laravel 5,我的项目包含index.blade.php和create.blade.php。 在create.blade.php中,是一个用于创建index.blade.php中列出的div的表单,通过该表单,我需要传递每个div的背景色,选项为红色、黄色和绿色 我的create.blade.php代码: <form action="{{url('warehouse')}}" method="post"> @csrf <label for="name" style="padding-righ

我的项目包含index.blade.php和create.blade.php。 在create.blade.php中,是一个用于创建index.blade.php中列出的div的表单,通过该表单,我需要传递每个div的背景色,选项为红色、黄色和绿色

我的create.blade.php代码:

<form action="{{url('warehouse')}}" method="post">
@csrf
<label for="name" style="padding-right:20px">Name</label>
<input type="text" id="name" name="name" style="padding-right:50px; margin-bottom:10px" placeholder="Name"><br>
<label for="supplier" style="padding-right:2px">Supplier</label>
<input type="text" id="supplier" name="supplier" style="padding-right:50px; margin-bottom:10px"
    placeholder="Supplier"><br>
<label for="type" style="padding-right:28.5px">Type</label>
<input type="text" id="type" name="type" style="padding-right:50px; margin-bottom:10px" placeholder="Type"><br>
<label for="url" style="padding-right:41.8px">Url</label>
<input type="text" id="url" name="url" style="padding-right:50px; margin-bottom:10px" placeholder="Url"><br>
<label for="color">Color</label>
<select id="selector" name="color">
    <option value="" disabled selected hidden>Please Choose...</option>
    <option value="green">Green (ready for sale)</option>
    <option value="yellow">Yellow (in progress)</option>
    <option value="red">Red (new)</option>
</select>
<br>
<button type="submit" id="kreiraj_dugme_create" onclick="selectBackground()">Create/button>
@foreach ($warehouses as $key => $warehouse)
<div class="brder1" draggable="true" ondragstart="drag(event,{{$key}})" id="{{$key}}">
    <h1 class="ime_palete">{{$warehouse->name}}</h1>
    <a class="link_palete" href="{{$warehouse->url}}" target="_blank">Link</a>
    <a class="edit_palete" href="{{url("warehouse/".$warehouse->id."/edit")}}">Edit</a>
    <a class="show_pallet" href="{{url("warehouse/".$warehouse->id)}}">Show</a>
    <form action="{{url("warehouse/".$warehouse->id)}}" method="post">
        @csrf
        @method('DELETE')
        <button type="submit" class="izbrisiDugme" onclick="remove()">Remove</button>
    </form>
</div>
@endforeach

</div>
<a class="create_palete" href="{{url("warehouse/create")}}">Create</a>

@csrf
名称

供应商
类型
网址
颜色 请选择。。。 绿色(待售) 黄色(进行中) 红色(新)
创建/按钮>
以及我的index.blade.php代码:

<form action="{{url('warehouse')}}" method="post">
@csrf
<label for="name" style="padding-right:20px">Name</label>
<input type="text" id="name" name="name" style="padding-right:50px; margin-bottom:10px" placeholder="Name"><br>
<label for="supplier" style="padding-right:2px">Supplier</label>
<input type="text" id="supplier" name="supplier" style="padding-right:50px; margin-bottom:10px"
    placeholder="Supplier"><br>
<label for="type" style="padding-right:28.5px">Type</label>
<input type="text" id="type" name="type" style="padding-right:50px; margin-bottom:10px" placeholder="Type"><br>
<label for="url" style="padding-right:41.8px">Url</label>
<input type="text" id="url" name="url" style="padding-right:50px; margin-bottom:10px" placeholder="Url"><br>
<label for="color">Color</label>
<select id="selector" name="color">
    <option value="" disabled selected hidden>Please Choose...</option>
    <option value="green">Green (ready for sale)</option>
    <option value="yellow">Yellow (in progress)</option>
    <option value="red">Red (new)</option>
</select>
<br>
<button type="submit" id="kreiraj_dugme_create" onclick="selectBackground()">Create/button>
@foreach ($warehouses as $key => $warehouse)
<div class="brder1" draggable="true" ondragstart="drag(event,{{$key}})" id="{{$key}}">
    <h1 class="ime_palete">{{$warehouse->name}}</h1>
    <a class="link_palete" href="{{$warehouse->url}}" target="_blank">Link</a>
    <a class="edit_palete" href="{{url("warehouse/".$warehouse->id."/edit")}}">Edit</a>
    <a class="show_pallet" href="{{url("warehouse/".$warehouse->id)}}">Show</a>
    <form action="{{url("warehouse/".$warehouse->id)}}" method="post">
        @csrf
        @method('DELETE')
        <button type="submit" class="izbrisiDugme" onclick="remove()">Remove</button>
    </form>
</div>
@endforeach

</div>
<a class="create_palete" href="{{url("warehouse/create")}}">Create</a>
@foreach($key=>$warehouse的仓库)
{{$warehouse->name}
@csrf
@方法('DELETE')
去除
@endforeach

我只需要将“选项”中的“背景色”设置为divbrder1

您可能需要这样做

使用jQuery:

 $("#selector").change(function(){
   $(".brder1").css('background-color', $(this).val());
});

您可以将代码放在documentready中。所以代码片段如下所示

$(document).ready(function(){
    $("#selector").change(function(){
        $(".brder1").css('background-color', $(this).val());
    });
});

是否希望每个brder1使用不同的背景色播放?是。。我从选项中选择什么来显示该颜色是的,我可以在某处与您联系吗?不太可能:-。。。但我相信你可以从那里接受。。。。