小编Jer*_*one的帖子

通过下拉菜单链接到HTML中的其他页面

我正在尝试通过下拉列表链接到其他html页面,我尝试了各种代码,但似乎无法让它工作.我正在使用此代码:

    <form name="dropdown">
<select name="list" accesskey="target">
<option selected>Choose a theme</option>
<option value="index.html">Theme 1</option>
<option value="theme2.html">Theme 2</option>
<option value="theme3.html">Theme 3</option>
<select>
<input type=button value="Go" onclick="goToNewPage(document.dropdown.list)">
Run Code Online (Sandbox Code Playgroud)

我有不同的html页面布局不同以在布局之间交替,我怎样才能使它工作?

html drop-down-menu

4
推荐指数
1
解决办法
5万
查看次数

在java中将两个整数数组合并为一个数组

我见过类似的问题而没有提供我正在寻找的答案,所以如果这被视为重复,我会提前道歉.我正在尝试将数组{1,2,3}和{4,5,6}组合成{1,2,3,4,5,6}.我做错了什么?我是java的新手.对不起,如果这个问题很愚蠢.

public class combine {
  public static void main(String[]args){

  int[]a = {1, 2, 3};
  int[]b = {4, 5, 6};
  int[]c = new int[a+b];
  for(int i=0; i<a.length; i++)
  System.out.print(c[i]+" ");
}
public static int[]merge(int[]a, int[]b){
  int[]c = new int[a.length+b.length];
  int i;
  for(i=0; i<a.length; i++)
     c[i] = a[i];

     for(int j=0; j<b.length; j++)
        c[i++]=b[j];
        return c;
}
}
Run Code Online (Sandbox Code Playgroud)

java arrays

4
推荐指数
3
解决办法
7万
查看次数

Ruby中的并行数组

我有两个数组,一个存储候选名称,另一个存储所述候选人的投票数.我正在尝试打印最大票数和相应候选人的姓名; 而不是诸如92, 4(投票数,候选人索引)之类的输出,输出类似的东西92, John.

这就像我必须这样做:

puts "Candidates, index order: 0, 1, 2, 3, 4"
candidates.each { |x| puts x }
puts "Votes, index order: 0, 1, 2, 3, 4"
votes.each { |y| puts y }

votes.delete(nil)
puts "Maximum number of votes, followed by candidates array index."
puts votes.each_with_index.max { |x,y| x <=> y }
Run Code Online (Sandbox Code Playgroud)

我成功获取了最大值所在的索引,但是如何使用该索引来匹配候选数组的索引以便打印名称而不是索引?

ruby

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

在javascript中的子悬停时更改父div的背景颜色?

我在 a 中有三个彩色框div,所有颜色都不同,当我hover在这些框中的任何一个上时,我必须使background-colordiv框的颜色与悬停在其上的内框的颜色相同。

CSS:

 .t1_colors {
    float: left;
    width: 100px;
    height: 100px;
    margin-right: 20px;
    border: 1px solid rgb(111,61,69);
    }
Run Code Online (Sandbox Code Playgroud)

HTML:

<div id="task1" class="task">
    <h2>Task 1</h2>
    <p>Change the background color, of the div that     contains this task, to the color in each box when the box is hovered over.</p>
    <p>When the mouse stops hovering over the box, change the background color back to white.</p>
    <div id="t1_color_one" class="t1_colors" style="background: goldenrod;"></div>
    <div id="t1_color_two" class="t1_colors" style="background: …
Run Code Online (Sandbox Code Playgroud)

html javascript css colors hover

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

如何在Java中的命令行中打印十字形?

我必须使用方法创建十字形状,参数是十字形的"大小".输入一个数字,如果数字是奇数,则绘制十字形,所以如果我输入一个5,输出看起来就像我添加到底部的截图

因为我上周才启动方法,所以中心线真的让我失望,但到目前为止,我有:

import java.util.Scanner;

public class Cross {

    public static void main(String[] arg) {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Please type a number: ");
        int num = keyboard.nextInt(); 
        drawCross(num);
    }

    public static void drawCross(int num){
        for (int = 1; i <= num; i++) {
            if ((num % 2) != 0) {
                System.out.println(i + "*");
            }
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

我知道这可能已经过时了,但我是方法的新手.

截图:

java

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

如何根据用户输入重启我的java程序?

我正在编写一个用于计算小型企业员工总销售额的程序,并且正在尝试根据用户输入的y/n来计算如何重新启动程序.我知道循环是我需要在这里使用的,但需要向正确的方向推进.

码:

import java.util.Scanner;
public class calcMain {
    public static void main(String[]args){
        double totalPay = 0, itemOne = 239.99, itemTwo = 129.75, itemThree =  99.95, itemFour = 350.89, commission;
    int weeklyBonus = 200, numSold;
    String employee1, employee2, employee3, employee4, yn;


    Scanner kb = new Scanner(System.in);
    System.out.println("Please enter the salesperson's name: ");
    employee1 = kb.nextLine();

    System.out.println("Please enter the number of Item 1 sold: ");
    numSold = kb.nextInt();
    totalPay += (itemOne * numSold);

    System.out.println("Please enter the number of Item 2 sold: "); …
Run Code Online (Sandbox Code Playgroud)

java

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

标签 统计

java ×3

html ×2

arrays ×1

colors ×1

css ×1

drop-down-menu ×1

hover ×1

javascript ×1

ruby ×1