HTML Body, Ty For help me.
<div class="bottoms_list">
<div class="One cell">
<button class="active"><span><i class="Picture"></i></span>1</button>
</div>
<div class="Two cell">
<button class=""><span><i class="Picture"></i></span>2</button>
</div>
<div class="three cell">
<button class=""><span><i class="Picture"></i></span>3</button>
</div>
<div class="four cell">
<button class=""><span><i class="Picture"></i></span>4</button>
</div>
</div>
Here button (1) is active.
Let's say I want to activate button (2).
I tried:
Dim spanpic As String = ""
For Each choice As HtmlElement In Form1.WebBrowser1.Document.GetElementsByTagName("div")
If choice.GetAttribute("className").Contains("bottoms_list") AndAlso choice.Id.StartsWith("2") Then
spanpic = choice.Id
For Each elm As HtmlElement In choice.Document.GetElementsByTagName("button")
If elm.GetAttribute("className") = "button" Then
elm.InvokeMember("click")
Exit For
End If
Next
End If
Next
'''''''''''''''''
Threading.Thread.Sleep(100)
Try
For Each elm As HtmlElement In
Form1.WebBrowser1.Document.GetElementById(spanpic).Document.GetElementsByTagName("button")
If elm.GetAttribute("className") = "bottoms_list" Then
If elm.GetAttribute("disabled") = "disabled" Then
Else
Exit For
End If
End If
Next
Catch
End Try
That's all I know, and I don't have good experience with element ids......................................
Try this :
"get collection of all div in the webpage"
For Each divSect As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
"get the div which has the tag of Two Cell"
If divSect.OuterHtml.Contains("Two Cell") then
"get the button inside the div which has the tag of Two Cell"
For Each elem as HtmlElement In divSect.children
If elem.GetAttribute("className") = "button" Then
elem.InvokeMember("click")
End if
Next
End if
Next
I hope those code could solve your problem.
look I'm not an expert either, but if you want to set a class "active" to the pressed button, then you should use class binding techniques in most of java-script frameworks.
For me I use VueJs and here's how I would do it:
HTML Body:
<div id="myList">
<div class="bottoms_list">
<div class="One cell">
<button #click="isActive = 1" :class="{active: isActive == 1}"><span><i class="Picture"></i></span>1</button>
</div>
<div class="Two cell">
<button #click="isActive = 2" :class="{active: isActive == 2}"><span><i class="Picture"></i></span>2</button>
</div>
<div class="three cell">
<button #click="isActive = 3" :class="{active: isActive == 3}"><span><i class="Picture"></i></span>3</button>
</div>
<div class="four cell">
<button #click="isActive = 4" :class="{active: isActive == 4}"><span><i class="Picture"></i></span>4</button>
</div>
</div>
</div>
then your Vue instance should look like this :
new Vue({
el: '#myList',
data: {
isActive: 0,
},
});
You can optimize this code to one line using the v-for directive.
Related
I have a vue select component, according to selection I want to change content, and show the loading screen on change event.
<template>
<div>
<div class="row component-separation audit-select">
<div class="col-md-4 pull-right">
<v-select
id="auditModeSelect"
:options="auditOptions"
label="label"
placeholder="Change Audit View Type"
class="form-control border-bottom"
v-model="auditOption"
#input="changeViewMode"
:clearable="false">
</v-select>
</div>
</div>
{{loadingTheContent}}
<div v-if="loadingTheContent">
<loading/>
</div>
<div v-else>
....
</div>
</div>
</template>
changeViewMode(selectedMode) {
this.loadingTheContent = true;
if (selectedMode && selectedMode.value === 1) {
...
} else {
...
}
this.loadingTheContent = false;
},
But loadingTheContent variable value is always false, not changing.
I also tried with adding custom button to trigger but same thing exists
So though my question might sound familiar the case is a bit different. I have a screen with multiple tasks. To show the tasks I am iterating via the data and my code looks something like
<div *ngFor="let task of tasks" class="scheduleContainer inline-block shadow">
<div id="myHeader" #myHeader class="activeHeader">
{{task.title}}
</div>
<div class="detailsBox">
<div class="row">
<div class="offset-md-1 col-md-auto">
Last Date:
</div>
<div class="col-md-auto">
{{task.lastDate}}
</div>
</div>
<div class="row">
<div class="offset-md-1 col-md-auto">
Duration:
</div>
<div class="col-md-auto">
{{task.duration}}
</div>
</div>
<div class="row">
<div class="offset-md-1 col-md-auto">
Total Runs:
</div>
<div class="col-md-auto">
{{task.totalRun}}
</div>
</div>
</div>
<div class="footer">
<a [routerLink]="['edit-scheduled-tasks']">edit schedule</a>
<a [routerLink]="['view-history-scheduled-tasks']">view history</a>
<a (click)="onClick()">enable task</a>
run now
</div>
</div>
<router-outlet></router-outlet>
Now when I click on the enabled task, I would like the color of that particular div to be changed. In my component, I tried something like
onClick() {
this.myHeader.nativeElement.style.background = 'red';
}
So this did change the color but it did not change the current task but rather some other task. Suggestions?
you can access myHeader from template so you can change the color something like this
<div id="myHeader" #myHeader class="activeHeader">
Change the color by myHeader variable
</div>
<button (click)="myHeader.style.background='red'">click</button>
or you can use a property with ngStyle like this
<div [ngStyle]="{'background-color':color}" >
Another way by ngStyle
</div>
<button (click)="color='red'">click</button>
or you can use a property to toggle class with ngClass
<div [ngClass]="{'red':isClicked}" >
Set class
</div>
<button (click)="isClicked=!isClicked">Toggle class</button>
Example toggle color of taskList by useing ngClass
template
<div *ngFor="let task of taskList"
[ngClass]="{'red':selectedTasks[task.id]}"
(click)="selectedTasks[task.id]= !selectedTasks[task.id]" class="task">
{{task.name}}
</div>
or you can use button to toggle the state
<div *ngFor="let task of taskList"
[ngClass]="{'red':selectedTasks[task.id]}"
class="task">
{{task.name}}
<button (click)="selectedTasks[task.id]= !selectedTasks[task.id]">toggle {{task.name}}</button>
</div>
if you want to set the state without toggle on click event just set
the state to true like this selectedTasks[task.id] =true
component
taskList =[
{id:1 , name:'Task 01'},
{id:2 , name:'Task 02'},
{id:3 , name:'Task 03'},
{id:4 , name:'Task 04'},
{id:5 , name:'Task 05'},
];
selectedTasks = {};
stackblitz demo
Not a clean way to do, but it still works. Send an index of selected element to onClick(i) and add the color to selected div. So that you don't mess with template reference.
html
<div *ngFor="let task of tasks; let i=index;" class="scheduleContainer inline-block shadow">
<div id="myHeader" #myHeader class="activeHeader">
{{task}}
</div>
<div class="footer">
<a (click)="onClick(i)">enable task</a>
</div>
</div>
component.ts
onClick(index: number) {
document.querySelectorAll('#myHeader')[index]
.style.background = 'red';
}
DEMO
It's not a good practice to manipulate DOM directly.
Angular: Stop manipulating DOM with ElementRef!
As an alternate, It's easy to bind inline style in your Angular templates using style binding.
Since you would like the color of that particular div to be changed. Use A boolean array:
component:
export class AppComponent {
name = 'Angular';
public styleArray=new Array<boolean>(10);
onClick(i)
{
this.styleArray[i]=true;
}
}
While Iterating pass index to onClick(i) to set particular index of array true and apply style dynamically
[style.color]="styleArray[i] ? 'green':'black'"
<div *ngFor="let task of tasks; let i=index" class="scheduleContainer inline-block shadow">
<div id="myHeader" [style.color]="styleArray[i] ? 'green':'black'" class="activeHeader">
{{task.title}}
</div>
........rest of the code
<a (click)="onClick(i)">enable task</a>
Live Demo
I am using AngularJS. I am generating pipeline-like structure. At first onload I am having one default ng-repeat value. After clicking "add more" I am displaying another list. It goes on adding as long as I am clicking the "add" button.
Here is my HTML:
Add button
<button data-ng-click="addNew()">Add New Workboard</button>
New pipeline will be created with Pipeline Names and one text box to add stageNames
<div data-ng-show="listOfLists.length > 0">
<div data-ng-repeat="list in listOfLists">
<div data-ng-repeat="pipeline in workboardstages track by $index">
<div class="added-eachboard">
<div class="form-group">
<input name="pipelineName" id="pipelineName" data-ng-
model="pipeline.pipelineName" type="text">
</div>
<ul class="simpleDemo workboard-drags" data-ng-repeat="(key,
workboardlist) in pipeline.workBoardStageMap">
<li data-ng-if="pipeline.pipelineName == key" ng-repeat="workboard in
workboardlist">{{workboard.stageName}}
<a href ="javascript:void(0)" data-ng-
click="editWorkboardStage(workboard.stageId)"><img src =
"resources/zingy/images/Edit-Small.png" class="TableIcon"></a>
</li>
</ul>
<div>
<p class="weak">Stage Name:</p>
<div class="form-group">
<input name="stageName" id="stageName" data-ng-
model="newworkboard.stageName" type="text">
</div>
</div>
</div>
</div>
</div>
</div>
Controller.js
$scope.listOfLists = [];
$scope.workboardStagesWithDefault = [
{
Name:"Test"
},
{
Name:"Test2"
},
{
Name:"Test3"
}
];
$scope.addNew = function(){
var clonedList = angular.copy($scope.workboardStagesWithDefault);
$scope.listOfLists.push(clonedList);
};
$scope.editWorkboardStage = function(stageId){
AccountService.editWorkboardStage(stageId).then(function(response){
$scope.newworkboard = response.data;
});
}
$scope.getAllWorkboardStages = function(){
AccountService.getAllWorkboardStages().then(function(response){
$scope.workboardstages = response.data;
$scope.listOfLists.push($scope.workboardstages);
});
}
After clicking edit i am displaying stage name in that particular text box.But the problem is it is displaying same for neighbouring pipeline also.I want to display only for that current pipeline.As i am displaying using ng-model it is taking for all pipelines.How to display the value only for that particular pipeline?
So, the problem is related to indexing. I made $scope.newworkboard index wise.
This is the solution: (newworkboard is based on pipeline index and pass index from editWorkboardStage function.)
<input name="stageName" id="stageName" data-ng-model="newworkboard[$index].stageName" type="text">
AND
<a href ="javascript:void(0)" data-ng-click="editWorkboardStage(workboard.stageId, $parent.$parent.$index)"><img src =
"resources/zingy/images/Edit-Small.png" class="TableIcon"></a>
HTML
<div data-ng-show="listOfLists.length > 0">
<div data-ng-repeat="list in listOfLists">
<div data-ng-repeat="pipeline in workboardstages track by $index">
<div class="added-eachboard">
<div class="form-group">
<input name="pipelineName" id="pipelineName" data-ng-
model="pipeline.pipelineName" type="text">
</div>
<ul class="simpleDemo workboard-drags" data-ng-repeat="(key,
workboardlist) in pipeline.workBoardStageMap">
<li data-ng-if="pipeline.pipelineName == key" ng-repeat="workboard in
workboardlist">{{workboard.stageName}}
<a href ="javascript:void(0)" data-ng-
click="editWorkboardStage(workboard.stageId, $parent.$parent.$index)"><img src =
"resources/zingy/images/Edit-Small.png" class="TableIcon"></a>
</li>
</ul>
<div>
<p class="weak">Stage Name:</p>
<div class="form-group">
<input name="stageName" id="stageName" data-ng-
model="newworkboard[$index].stageName" type="text">
</div>
</div>
</div>
</div>
</div>
</div>
Controller
In the controller make an array of newworkboard and assign response.data index wise.
$scope.newworkboard = [];
$scope.editWorkboardStage = function(stageId, index){
AccountService.editWorkboardStage(stageId).then(function(response){
$scope.newworkboard[index] = response.data;
});
How do i give the showProduct:boolean = false; value to the app-product html selector so it will be false at start?
showProduct:boolean = false;
<button (click)="showProduct=!showProduct">Show Product</button>
<div *ngIf="!showProduct">
<app-product></app-product>
</div>
I think you need <div *ngIf="showProduct">,
<button (click)="showProduct=!showProduct">Show Product</button>
<div *ngIf="showProduct">
<app-product></app-product>
</div>
I'm battling to get a dropdownlist and button on the same line in a bootstrap modal. I've tried using <,span> but it doesn't work.
<div class="col-md-12 hSpacerMob">
<div class="well">
using (Html.BeginForm("AddPlayerSignup", "SignupSheet"))
{
#Html.DropDownList("Member", tournament.SignupSheet.GroupMembers)
<span>
#Html.SubmitButton("Add", true, new { #class = "btn btn-primary" })
</span>
}
#Html.ActionLink("Pause", "ChangeState", "SignupSheet", new { Paused = true }, new { #class = "btn btn-warning" })
</div>
</div>
So I need the dropdown and 'Add' button on the same line next to each other and the pause button below, but as it stands they're just displayed below each other.
edit: I tried using row but that also does not work
<div class="row">
<div class="col-md-6">
#Html.DropDownList("Member", ladder.SignupSheet.GroupMembers, new {label = "Members", #class = "pull-left form-control", #style = "width:200px"})
</div>
<div class="col-md-6">
#Html.SubmitButton("Add member", true, new {#class = "btn btn-primary"})
</div>
</div>
bootstrap has input groups for combining inputs and buttons that you might want to try
<div class="input-group">
#Html.DropDownList("Member", tournament.SignupSheet.GroupMembers)
<div class="input-group-btn">
#Html.SubmitButton("Add", true, new { #class = "btn btn-primary" })
</div>
</div>
I finally figured out the problem! My submit button has a 'true' overload for the 'container' bool, when it should be false. Having it set to true added the 'form actions' styling which adds a margin-top:30px element. So as soon as I set that to false it works.
<div class="row">
<div class="col-md-6">
#Html.DropDownList("Member", ladder.SignupSheet.GroupMembers, new {label = "Members", #class = "pull-left form-control", #style = "width:200px"})
</div>
<div class="col-md-6">
#Html.SubmitButton("Add member", false, new {#class = "btn btn-primary"})
</div>
</div>