pagokoftis
12-09-2010, 02:10 PM
Hello, I have a problem with the following code!
I want to use it so that customers check a checkbox under each photo they want, in a photo gallery, and when they finish, they can click and the photos they checked appear using document.write in a new page!
The problem I have is that when the script finds the first image, it uses document.write, shows only the first image it finds and then ends the foor loop!
How can I code it so that it finds all the photos first and then shows them in the new page!
Here is the sample code, sorry for my bad English and thanks for your time!
--------------------------------------------------------------------------
<script type="text/javascript">
function findphotos(test){
for (i=0; i<document.test.checkgroup.length; i++){
if (document.test.checkgroup[i].checked==true){
document.write('<img src="'+i+'.jpg">');
}
}
}
</script>
<form name="test">
<input type="checkbox" name="checkgroup" />
<input type="checkbox" name="checkgroup" />
<input type="checkbox" name="checkgroup" />
</form>
<h1 onclick="javascript:findphotos(test)">Find</h1>
I want to use it so that customers check a checkbox under each photo they want, in a photo gallery, and when they finish, they can click and the photos they checked appear using document.write in a new page!
The problem I have is that when the script finds the first image, it uses document.write, shows only the first image it finds and then ends the foor loop!
How can I code it so that it finds all the photos first and then shows them in the new page!
Here is the sample code, sorry for my bad English and thanks for your time!
--------------------------------------------------------------------------
<script type="text/javascript">
function findphotos(test){
for (i=0; i<document.test.checkgroup.length; i++){
if (document.test.checkgroup[i].checked==true){
document.write('<img src="'+i+'.jpg">');
}
}
}
</script>
<form name="test">
<input type="checkbox" name="checkgroup" />
<input type="checkbox" name="checkgroup" />
<input type="checkbox" name="checkgroup" />
</form>
<h1 onclick="javascript:findphotos(test)">Find</h1>