我的textarea有一个值,但它没有显示在textarea中,它在我的输入字段中工作...
<textarea value="This text is not visible"></textarea>
<input value="This text is visible">Run Code Online (Sandbox Code Playgroud)
如果我选中左边的复选框之一,我希望它旁边的复选框将被启用。如果我取消选中左侧复选框之一,则应再次禁用它旁边的复选框:
$('input[type="checkbox"]').change(function () {
$("input:checkbox:checked:not(.delivery)").each(function () {
if ($("input:checkbox:checked").length > 0) {
$(this).closest("tr").children('.disable').removeAttr("disabled");
} else {
$(this).closest("tr").children('.disable').addAttr("disabled");
}
});
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td><input type="checkbox"></td>
<td><input class="disable" disabled="" type="checkbox"></td>
</tr>
<br>
<tr>
<td><input type="checkbox"></td>
<td><input class="disable" disabled="" type="checkbox"></td>
</tr>Run Code Online (Sandbox Code Playgroud)
使用我的代码,它保持禁用状态。
我想noclick从click函数中排除该类:
$( ".click" ).on( "click", ":not(.noclick *)", function() {
console.log( $( this ).text() );
});Run Code Online (Sandbox Code Playgroud)
.noclick{
background-color:pink;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table style="width:100%">
<tr class="click">
<th>Click</th>
<th>Click</th>
<th class="noclick">Nothing should happen here</th>
</tr>
</table>Run Code Online (Sandbox Code Playgroud)
我正在从一个文件创建一个数组:
$handle = fopen("inputfile.txt", "r");
if ($handle) {
while (($str = fgets($handle)) !== false) {
if (strlen($str) && $str[0] == '#') {
$pdate = substr($str, 1);
$date = rtrim($pdate);
$formatted = DateTime::createFromFormat('* M d H:i:s T Y',$date);
}
rtrim ($str, "\n");
$exp = explode ('=', $str);
if(count($exp) == 2){
$exp2 = explode('.', $exp[0]);
if( count($exp2) == 2 ) {
if($exp2[1] == "dateTime"){
$s = str_replace("\\","",$exp[1]);
$d = strtotime($s);
$dateTime = date('Y-m-d H:i:s', $d);
$properties [$exp2[0]][$exp2[1]] = $dateTime;
} else { …Run Code Online (Sandbox Code Playgroud) 我收到一条错误消息,没有找到"GET/users"的路由:
级别:错误,频道:请求,消息:未捕获的PHP异常Symfony\Component\HttpKernel\Exception\NotFoundHttpException:"在/ Users/work/project/vendor/symfony/http-kernel /"找不到"GET/users"的路由EventListener/RouterListener.php第139行
但实际上我为"用户"设置了一条路线,所以我不知道如何解决这个问题:
<?php
namespace App\Controller;
use DataTables\DataTablesInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
/**
*
* @Route("/users", name="users")
*
* @param Request $request
* @param DataTablesInterface $datatables
* @return JsonResponse
*/
class DataTableController extends Controller
{
const ID = 'users';
public function usersAction(Request $request, DataTablesInterface $datatables): JsonResponse
{
try {
// Tell the DataTables service to process the request,
// specifying ID of the required handler.
$results = $datatables->handle($request, 'users');
return $this->json($results);
}
catch (HttpException $e) { …Run Code Online (Sandbox Code Playgroud) 我正在使用Symfony探查器。但是我实际上只想使其在开发模式下可见。但是,当我通过git在服务器上推送数据并打开网站时,我看到了探查器。那没有道理,但我不知道如何消除。
我一直在寻找名为的文件config/config_dev.yml,config/config.yml因为我认为config/config.yml应该将其设置为:
web_profiler:
toolbar: false
intercept_redirects: false
Run Code Online (Sandbox Code Playgroud)
但是我没有任何config.yml文件。我必须创建它们吗?
我在Controller中创建了一个与Entity一起使用的函数Members.我现在要做的是使功能灵活,这样我就可以将它用于我所有其他实体.因此,实体的名称应该取决于slug.所以在这种情况下slug = members:
/**
* @Route("/pages/{slug}/forms", name="forms", methods={"POST", "GET"})
*/
public function form($slug, Request $request){
$item = new Members();
$item= $this->getDoctrine()->getRepository(Members::class)->find($id);
}
Run Code Online (Sandbox Code Playgroud)
所以我要做的是用slug替换实体名称:
/**
* @Route("/pages/{slug}/forms", name="forms", methods={"POST", "GET"})
*/
public function form($slug, Request $request){
$item = new $slug();
$item= $this->getDoctrine()->getRepository($slug::class)->find($id);
}
Run Code Online (Sandbox Code Playgroud)
但是我收到一条错误消息:
尝试从全局命名空间加载类"成员".你忘记了"使用"声明吗?
这是否与slug的大写/小写有关?
我有一个简单的选择框:
<select class="select">
<option data-number="0" disabled>0</option>
<option data-number="1" disabled>1</option>
<option data-number="1" disabled>2</option>
</select>
Run Code Online (Sandbox Code Playgroud)
如果data-number为0,disabled则应删除该属性.我这样做的方式不起作用:
$(#'input').change(function () {
if ($('.select').data('number') == 0) {
alert("Hello! This working!!");
$(this).data('number').prop('disabled', false);
}
});
Run Code Online (Sandbox Code Playgroud)
当我选择时,我没有收到警报0(注意:我当然无法手动选择禁用选项,但系统会在输入更改时自动选择它)
在我的控制器中,我使用了很多扩展类型:
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
Run Code Online (Sandbox Code Playgroud)
因为这需要很多空间并且对我来说不清楚,我需要知道是否有一行只使用所有行.像这样的东西:
use Symfony\Component\Form\Extension\Core\Type\AllTypes;
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过学说从我的数组集合中加载数据:
$pages = $this->em->getRepository(Pages::class)->findAll();
Run Code Online (Sandbox Code Playgroud)
结果是:
2 => Pages^ {#1598 ?
-id: 3
-name: "cat"
-membergroup: PersistentCollection^ {#1603 ?
-snapshot: []
-owner: Pages^ {#1598}
-association: array:16 [ …16]
-em: EntityManager^ {#278 …11}
-backRefFieldName: "pages"
-typeClass: ClassMetadata {#693 …}
-isDirty: false
#collection: ArrayCollection^ {#1604 ?
-elements: []
}
#initialized: false
}
Run Code Online (Sandbox Code Playgroud)
}
问题是,我希望成员组 ArrayCollection 中有一个元素。但它是空的。
我想知道我的数组中是否有数字:
array(1) { [0]=> string(5) "3,4,5" }
if (in_array('3', $array)) {
echo 'in array';
} else {
echo 'not in array';
}
Run Code Online (Sandbox Code Playgroud)
结果是,not in array但我期待in array