标签: dynamically-generated

根据标题标记自动生成嵌套的目录

哪位狡猾的程序员可以向我展示一个优雅的PHP编码解决方案,用于根据页面上的标题标签自动生成嵌套的目录?

所以我有一个html文件:

<h1> Animals </h1>

Some content goes here.
Some content goes here.

<h2> Mammals </h2>

Some content goes here.
Some content goes here.

<h3> Terrestrial Mammals </h3>
Some content goes here.
Some content goes here.

<h3> Marine Mammals </h3>
Some content goes here.
Some content goes here.

<h4> Whales </h4>
Some content goes here.
Some content goes here.
Run Code Online (Sandbox Code Playgroud)

更具体地说,我想要一个链接的目录,其形式是在同一页面上的标题链接的嵌套列表:

目录(由PHP代码自动生成)

  1. 动物
    1. 哺乳动物
      1. Terrestrial_Mammals
      2. Marine_Mammals
        1. 鲸鱼

php dynamically-generated

2
推荐指数
4
解决办法
7091
查看次数

使用Javascript扩展侧边栏高度以等同内容高度

我有一个简单的javascript函数,它意味着增加我的侧边栏div的高度,使其等于内容div的高度.这就是我这样做的方式....

使用Javascript:

<script type="text/javascript">
function absar(){
document.getElementById("sidebar").style.height = document.getElementById("content").clientHeight;
    }</script>
Run Code Online (Sandbox Code Playgroud)

HTML:

<body onLoad="absar()">
<div id="sidebar" style="border:1px solid red">Few content</div>
<div id="content" style="border:1px solid red">
some content <br>
some content <br>
some content <br>
some content <br>
some content <br>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)

此代码将使侧边栏的高度等于内容div的高度.**好**

但是当我在wordpress中粘贴相同的代码(我有相同的id值content&sidebar)时,在body标签之后onload="absar()"它提供给body,它什么也没做,什么都没做.

此时,当我设计几乎整个布局时,我不能使用像Faux Columns或table等新的解决方案.

html javascript height dynamically-generated

2
推荐指数
1
解决办法
3196
查看次数

动态创建的Winform组合框都选择相同的值

我正在用C#和VS 2010 Ultimate创建一个winform应用程序.我正在使用动态创建的combox填充flowlayoutpanel,所有这些都被数​​据绑定到相同的绑定列表.当我运行应用程序时,它会正确添加combox,但是当我在一个组合框中选择一个项目时,所有其他项目都会使用相同的选项进行更新.我究竟做错了什么?非常感谢您收到的任何帮助.J.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace TestCompleteForm
{
public partial class Form1 : Form
{
    private int comboBoxIndex = 0;
    List<string> Existingfiles;
    BindingList<string> ExistingSystemsList;
    List<string> Selectedfiles;
    BindingList<string> SelectedSystemsList;
    BindingList<string> ListOfLanguages = new BindingList<string>();
    BindingList<string> ListOfSQLServers = new BindingList<string>();

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        DirectoryInfo dinfo = new DirectoryInfo(@"C:\Hosts");
        FileInfo[] Files = dinfo.GetFiles("*.txt");
        Existingfiles = new …
Run Code Online (Sandbox Code Playgroud)

c# combobox bindinglist dynamically-generated

2
推荐指数
1
解决办法
1428
查看次数

动态调整Facebook Like Box的大小 - 响应式更改data-width ="{n}"

Facebook代码:

<div class="fb-like-box" data-href="http://stackoverflow.com/" data-width="160" data-height="100" data-colorscheme="light" data-show-faces="false" data-header="false" data-stream="false" data-show-border="false"></div>
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用javascript或CSS媒体查询在屏幕大小更改(智能手机/平板电脑方向更改)上动态更改data-width ="{n}"和/或data-height ="{n}".

javascript css css3 dynamically-generated responsive-design

2
推荐指数
1
解决办法
7905
查看次数

在C++中生成随机非重复数组

我需要在C++中生成随机非重复数组,在这部分代码中我使用srand函数生成随机数,但有些数字是重复的.主要任务是为彩票生成随机数,所以我需要生成数字,直到标记为int golden的黄金数字.

#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
  int golden = 31;
  int i = 0;
  int array[35];

 srand((unsigned)time(0));
    while(i != golden){
        array[i] = (rand()%75)+1;
        cout << array[i] << endl;
        i++;
}
 }
Run Code Online (Sandbox Code Playgroud)

c++ arrays random dynamically-generated

2
推荐指数
1
解决办法
3209
查看次数

AngularJs使用SubMenu创建上下文菜单

我想用angularjs在指令中创建一个上下文菜单,我可以创建一个菜单但不能用子菜单创建.我的意思是,在悬停时打开子菜单.

示例小提琴:示例上下文菜单

我的控制器:

$scope.menuOptions = [
        ['New User', function () {
           console.log("New User");
        }],
        ['Delete', function () {
           console.log("Delete");
        }]
    ]; 
Run Code Online (Sandbox Code Playgroud)

这个小提琴是非常好的,只有我想在这个上下文菜单中添加子菜单.如何根据此示例创建子菜单?

javascript model-view-controller contextmenu dynamically-generated angularjs

2
推荐指数
1
解决办法
3570
查看次数

JQ:生成带有json信息的txt文件

我有以下 Json:

[{
    "_id": {
            "$oid": "59c3942baeef22b03fa573d2"
    },
    "client_id": "test@test.com",
    "name": "Windows Client"
},
{
    "_id": {
            "$oid": "59c3942baeef22b03fa573d2"
    },
    "client_id": "test2@test2.com",
    "name": "Linux Client"
}]
Run Code Online (Sandbox Code Playgroud)

我想输出以下内容:

mongo_customers,customer=test@test.com
mongo_customers,customer=test2@test.com
Run Code Online (Sandbox Code Playgroud)

我已尝试以下方法,但它不起作用:

jq -n -R \
  --slurpfile mongo mongo.json \
'
  $mongo[][].client_id] as $mongo_ids
  "mongo_customers,customer="($mongo_ids)
'
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

text json dynamically-generated jq

2
推荐指数
1
解决办法
421
查看次数

向动态加载的组件添加事件处理程序

我有两个组成部分:workflowblock.所述block组件被动态加载到workflow使用directiveComponentFactory.

block组件包含一个按钮,我想发出一个事件(父workflow)被点击的按钮时,因此,我加入@Output('onDelete') onDelete = new EventEmitter<boolean>()BlockComponent为了能够发射该事件.

我遇到的问题是添加event handler<app-block>.我尝试使用document.getElementsByTagName('app-block').addEventListener('(onDelete)', 'blockDeleted()') 它添加它,但它不起作用.

workflow.component.html

<div clas="mainContent">
  <ng-template appWorkflowDirective></ng-template>
</div>
Run Code Online (Sandbox Code Playgroud)

workflow.component.ts

private createNewBlockComponent(event, object): void {
   const componentFactory = this.componentFactoryResolver.resolveComponentFactory(BlockComponent);
   const componentRef = this.workflowsDirective.viewContainerRef.createComponent(componentFactory);

   (<BlockComponent>componentRef.instance).position = new BlockPosition(event.layerX, event.layerY) ;
}
Run Code Online (Sandbox Code Playgroud)

我在寻找相同的行为在这个例子从角

dynamically-generated eventemitter typescript angular

2
推荐指数
1
解决办法
2960
查看次数

CSS通过id递增

我有一组由javascript生成的文本框.其中一些文本框需要额外的CSS样式.我不能使用id属性,因为只有一些文本框需要这种样式.我也不能使用class属性,因为它在所有文本框中都是相同的.

我目前正在使用这样的CSS:

#txtSys8
{
position: relative;
left: 203px;
}

#txtSys9
{
position: relative;
left: 203px;
}

#txtSys10
{
position: relative;
left: 203px;
}
Run Code Online (Sandbox Code Playgroud)

有没有一种方法可以循环使用这些ID(从#txtSysy8到#txtSys19)而无需单独设置样式?

这是生成html的代码

rssTag ="<TABLE id='rssTable' border=\"0\" width=\"100%\"><TBODY>";

for(var i=8; i<arrGridData.length; i++){

var upToNCharacters = arrGridData[i][0].substring(0, 13);

if(upToNCharacters == "RSS_FEED_LINK"){
rssTag+="<TR><TD><font>" + arrGridData[i][1] + ":</TD><TD>  <input type=\"text\" id=\"txtSys"+i+"\" name=\"txtSys"+i+"\" onChange=\"pgEdited()\" tabindex=\" " +(i+1) +"\" class=\"fontDefault\"></TD><TD><input type=\"checkbox\" id=\"check" + arrGridData[i][0].substring(14, arrGridData[i][0].toString().length) + "\" name=\"check\" onChange=\"pgEdited()\" class=\"chk\"/></TD></TR>";

        }else{
rssTag+="<TR><TD><font>" + arrGridData[i][1] + ":</TD><TD><input type=\"text\" id=\"txtSys"+i+"\" name=\"txtSys"+i+"\" onChange=\"pgEdited()\" tabindex=\" " +(i+1) …
Run Code Online (Sandbox Code Playgroud)

javascript css styles dynamically-generated

1
推荐指数
1
解决办法
1703
查看次数

在 Rails 4 中动态创建哈希键名

是否可以动态创建散列的键名?我正在传递以下哈希参数:

params[:store][:store_mon_open(5i)]
params[:store][:store_mon_closed(5i)]
params[:store][:store_tue_open(5i)]
params[:store][:store_tue_closed(5i)]
.
.
.
params[:store][:store_sun_open(5i)]
params[:store][:store_sun_closed(5i)]
Run Code Online (Sandbox Code Playgroud)

为了检查每个参数是否存在,我使用了两个数组:

days_of_week = [:mon, :tue, ..., :sun]
open_or_closed = [:open, :closed]
Run Code Online (Sandbox Code Playgroud)

但是,我似乎无法弄清楚如何动态创建 params 哈希(第二个键(带有数组。这是我到目前为止所拥有的:

days_of_week.each do |day_of_week|
  open_or_closed.each do |store_status|
    if !eval("params[:store][:store_#{day_of_week}_#{store_status}(5i)").nil
      [DO SOMETHING]
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

我尝试了很多方法,包括 eval 方法(如上所列),但 rails 似乎不喜欢“5i”周围的括号。任何帮助是极大的赞赏!

arrays parameters hash ruby-on-rails dynamically-generated

1
推荐指数
1
解决办法
3423
查看次数