0
<script>
var itemsAdded = Array();

function moveNumbers(text) { 
var i = itemsAdded.indexOf(text)
if ( i >= 0) { 
   itemsAdded.splice(i,1); 
} else {
   itemsAdded.push(text);
}
document.getElementById("list").value=itemsAdded.join("");

}

$(function() {
for (i=0;i<10;i++) {
console.log(i);
$("body").append("<input type='checkbox' id='list' name='list' value='"+ i +"' onclick='moveNumbers(this.value)'/> Checkbox"+ i +"<br/>");      
}
});

<legend>5x7</legend>
<input type="text" name="list" id="list"  style="width:800px; background:#B0D2D7">

<legend>Print size</legend>
<input style='width:20px; height:20px; background-color: #ff6633;'
type='checkbox' id='list' name='list' value='$file - 5x7,'
onclick='moveNumbers(this.value)'>5x7

Hi all, new at this stuff so here goes, I have this so far which all works fine. It displays check boxes next to images that are displayed on web page via a PHP script. When checked it displays the file name and the image print size inside of a text box.

I tried to add more check boxes / text boxes with another print size say 6x8 and repeat the script with some changes. It sort of worked but not correctly. Any ideas would be great! Cheers.

4

1 に答える 1

0

何を達成しようとしているのかわかりませんが、チェックボックスの値を取得したい場合は、たとえば次のように簡単に値を取得できます。

<html>
<head>
<script>
function check(id)
{
if ( document.getElementById(id).checked){
var vl=document.getElementById(id).value;
document.getElementById("txt1").value += vl;
}
}
</script>

</head>
<input type="checkbox" id='1' onClick='check(1)' value="5*7-">5*7
<input type="checkbox" id='2' onClick='check(2)' value="5*8-">5*8
<input type="textbox" id="txt1" name=one>
</html>
于 2013-08-25T13:38:21.190 に答える