How to append serial number in activeForm form attribute - yii2

Trying to display questions from table, I want display serial number before that question.
I tried but I am getting number in one line and question is other line.
EX:
<?= $index+1 . $form->field($practiceTest, "[$index]question")->textarea(['readonly'=> true]) ?>
Can any one give an idea how to display number after question like.
Ex: 1. question

You can try to use Ordered List in case when you need to get numbers calculated.
<ol type="1">
<!-- I guess here you iterate to get index -->
<li>
<?= $form->field($practiceTest, "[$index]question")->textarea(['readonly'=> true]) ?>
</li>
<!-- Finish iteration -->
</ol>
Hope it will helps

Related

JSTL Pagination for foreach loop

I have been trying to add pagination for JSTl function but i am not able to achieve it. Here is an exapmple of my code below:
<c:forEach items="{items}" var ="item" varstatus="count" begin="1" end="13">
<div>
printing some attributes of items;
</div>
</c:forEach>
<ul>
<li>1<li>
<li>2<li>
<li>3<li>
<li>4<li>
.
.
</ul>
Each page should contain 13 items and the length of items in dynamic
so accordingly i need to display the pagination tab at the end of each page and display 13 items per page. Once i click on the number respective set of 13 items should be displayed.
Please help
Try to follow this tutorial -> Link
This task needs fair knowledge of JSTL tags, creating appropriate
pagination url, displaying total and numbers per page, dynamic updating of
records showing in each page (for example 13, 26, 39 ...), appropriate data retrieval, ETC.You need to study all those to
successfully implement this task. The link I sent you will help you with that.

Yii2 assign values according to the previous ones

I have a 2 dropdown menus, which is in my form. I have created 2 databases: category and item, their structure is below:
category database:
id, name
item database:
id, category_id, name, price.
I manually stored data inside of it (in the category I stored Computers, Cars and Phones and according to the categories id I manually stored items.
So I have 2 dropDownMenus, one is category name and the other is item name. Here is what I need to do:
If the user selects f.e computer categories, automatically items dropdownmenu should show computer items and so on. Could someone explain how it can be solved? I guess I should show that the item dropdown menu should show the values according to the category_id, but i'm not sure.
Here is my view file, where is those 2 dropdown menus:
<?= $form->field($model, 'code') ?>
<?= $form->field($category, 'name')->dropDownList(
ArrayHelper::map(Category::find()->All(),'id','name')) ?>
<?= $form->field($item, 'name')->dropDownList(
ArrayHelper::map(Item::find()->All(),'id', 'name')) ?>
I hope that you understand my problem, thanks for any help.

how to retrieve a value from a div in html file using xpath

<li class="col-xs-12 padding-lr-reset">
<div class="left-header pull-right padding-left-title">
GPU
</div>
<div class="right-description width-li-spec pull-right ltr text-align-right">
Adreno 405
</div>
</li>
I', using import.io to retrieve mobile specification from a table in a persian website but problem is some fields and values always moves in other phone's specifications.for example ,I'm trying to use xpath to find any value for gpu field in whole table.
Sorry for my bad English !
here is the source code
to get the required value, here is the xpath:
normalize-space(.//div[normalize-space(.) = 'GPU']/following-sibling::div[1]/text())
Where div[normalize-space(.)='GPU'] search for all the div nodes that its clean text is equal to GPU, and following-sibling::div[1] takes the first div node after those nodes that normalize-space(.) = 'GPU' has returned
I tested it and it gives :
u'Adreno 405

How to remove last two tabs in the products description?

In a Magento site, on product page, product description section their are five tabs. I want to remove last 2 tabs. It is coming from
($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html)
code.
So by which way I should remove the tabs, please can any one help me to solve this issue.

Keeping Form id like numerical value in the HTML Dom Element

In my application i want to keep my Form id in the Dom element So that on click of my Dom element, i get to know the Form id and make use of that for further purpose.
For eg:
my app has a list of form names generated like
Contact Form
Personal Form
I want to save my form id that is 1 somewhere in the Dom element a.
And onclick of that link i want to make use of it for further things . How can i do .. Where can i save my Form id in the Dom element.Please suggest me..
Edit:
In my application by using JQuery, i am generating list of Form names by fetching it from by MYSQL database using CakePHP framework.
eg:
$('#entryManager').click(function(){
$("<p class='title2'>Forms</p>").appendTo("#fb_contentarea_col1top");
$("<ul class='formfield'>").appendTo("#fb_contentarea_col1down");
<?php foreach ($Forms as $r): ?>
$("<li><a id=Form'<?=$r['Form']['id'];?>' href='/FormBuilder/index.php/main/entryManager'><?=$r['Form']['name']?></a></li>").appendTo("#fb_contentarea_col1down .formfield");
<?php endforeach; ?>
return false;
});//entry Manager Click
On click of Entry manager the Form names are listed .
And now i want to use some function like onclick of each Form name i want to retrieve the Entries filled by invitees from the database.For this i want the FOrm id each Form name to store it somewhere in the DOm element so that i can get that value (form id) and send it to my ajax request to fetch the entries filled..How can i do so???
Don't use purely numeric id's, it's best if they start with a letter, but essentially you can can have...
<form id="form1"...>
And then store the information in your anchor like this...
<a rel="form1">Click...
Then you can pull the "rel" tag out and use it to reference form1.
This is technically stretching the purpose of the rel tag, but does work.
document.forms is an array that contains all of your forms and you can do something like this:
document.forms['myFormId'] and you would get the form of that ID. But yet I am not getting what you are trying to achieve. May be if you elaborate on it further then I can guide you better on this.