0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

javascriptで数字と空白で5個あるinput textを"3 4 5"で選択する方法

Posted at

概要

javascriptで数字と空白で5個あるinput textを"3 4 5"で選択する方法を書く。

写真

image.png

サンプルコード


var out = document.getElementById("out");
var src = document.getElementById("src"); 
var ank = [
  ["問題1", "①考えている", "②どちらともいえない",	"③今は考えていない", "④-"],
  ["問題2", "①考えている", "②どちらともいえない",	"③今は考えていない", "④-"],
  ["問題3", "①考えている", "②どちらともいえない",	"③今は考えていない", "④-"],
  ["問題4", "考えている", "どちらともいえない",	"今は考えていない", "-"],
  ["問題5", "考えている", "どちらともいえない",	"今は考えていない", "-"]
];
for (var i = 0; i < ank.length; i++)
{
  out.value += ank[i][0] + "\n";
}

function run() {
  for (var i = 0; i < 5; i++)
  {
    for (var j = 0; j < 5; j++)
    {
      var s = "out" + i + j;
      out = document.getElementById(s);
      out.value = "";
    }
  }
  var mondai = src.value.split(" ");
  for (var i = 0; i < mondai.length; i++)
  {
    for (var j = 0; j < 5; j++)
    {
      var s = "out" + i + j;
      out = document.getElementById(s);
      out.value = ank[mondai[i] - 1][j];
    }
  }
}





成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?