Is it ok to mix doc.getElementById stmts
with document.main_fm.upLoad1.value stmts im the same form. ?
This is what I am trying to do below but my onclick cmd doesn’t change the contents of the browse box (it should clear it).
[CODE]<form name=”main_fm” enctype =”multipart/form-data” action=”a_picts.php” method=”POST”>
<input type = ‘hidden’ name=’run’ value=”on”>
<input type=”hidden” name =”MAX FILE SIZE” value=”500000″>
<input type = ‘hidden’ name=’adref’ value=”<?php echo $A_ref ?>”>
<div style=’position:absolute; left:40px; top:320px’ >
<b>First image:</b><br />
<input type=”file” size=”50″ id = “u1″ name=”upLoad1″ onchange=”showImg1()”><br />
<input type=”text” size=”50″ id = “n1″ name=”fName1″ readonly>
<input type=”button” value =”reset” onclick=”document.getElementById(‘u1’).value=”;document.main_fm.upLoad1.value=”;document.getElementById(‘image1’).src=”;document.getElementById(‘image1′).style.display=’none'”>
</div>
<div style=’position:absolute; left:500px; top:262px’ >
<img height=’160′ width=’160′ id=”image1″ style=’display:none’ />
</div>
Any ideas about where I am going wrong ?
Thanks
Moz FF clears both boxes very nicely ![/QUOTE]
The downside is ofcourse - Moz FF doesn't displat the image but IE does
(IE 6 not IE 7)[/QUOTE]
[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
var IE = true;
if (navigator.appName != "Microsoft Internet Explorer"){IE = false}
function showImg1(){
var fullName = document.main_fm.upLoad1.value;
var fileName = fullName.match(/[^/\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
{
if (IE)
{
document.getElementById('image1').style.display = '';
document.getElementById('image1').src = fullName;
}
document.main_fm.fName1.value = 'Picture file name: '+fileName;
}
else {
alert('Invalid file type');
}
}
function showImg2(){
var fullName = document.main_fm.upLoad2.value;
var fileName = fullName.match(/[^/\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
{
if (IE)
{
document.getElementById('image2').style.display = '';
document.getElementById('image2').src = fullName;
}
document.main_fm.fName2.value = 'Picture file name: '+fileName;
}
else {
alert('Invalid file type');
}
}
function showImg3(){
var fullName = document.main_fm.upLoad3.value;
var fileName = fullName.match(/[^/\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
{
if (IE)
{
document.getElementById('image3').style.display = '';
document.getElementById('image3').src = fullName;
}
document.main_fm.fName3.value = 'Picture file name: '+fileName;
}
else {
alert('Invalid file type');
}
}
function showImg4(){
var fullName = document.main_fm.upLoad4.value;
var fileName = fullName.match(/[^/\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
{
if (IE)
{
document.getElementById('image4').style.display = '';
document.getElementById('image4').src = fullName;
}
document.main_fm.fName4.value = 'Picture file name: '+fileName;
}
else {
alert('Invalid file type');
}
}
function showImg5(){
var fullName = document.main_fm.upLoad5.value;
var fileName = fullName.match(/[^/\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
{
if (IE)
{
document.getElementById('image5').style.display = '';
document.getElementById('image5').src = fullName;
}
document.main_fm.fName5.value = 'Picture file name: '+fileName;
}
else {
alert('Invalid file type');
}
}
</script>
</head>
<body>
<!-- Using a linked stylesheet -->
<link rel="STYLESHEET" type="text/css" href="yodbod.css">
<img alt="header (13K)" src="flashtest1.jpg" height="130" width="920" />
<div style='width:600px; position:absolute; left:40px; top:160px' >
<b><big>Adding pictures to your advert.</big></b><br>
<b>Select your picture files from your computer using the browse buttons.</b><br />
You can have up to five photos for all catagories except Jobs and Careers<br />
which excepts only one (we couldn't see any reason for more!).<br />
</div>
<form name="main_fm" enctype ="multipart/form-data" action="a_picts.php" method="POST">
<input type = 'hidden' name='run' value="on">
<input type="hidden" name ="MAX FILE SIZE" value="500000">
<input type = 'hidden' name='adref' value="<?php echo $A_ref ?>">
<div style='position:absolute; left:40px; top:320px' >
<b>First image:</b><br />
<input type="file" size="50" id = "u1" name="upLoad1" onchange="showImg1()"><br />
<input type="text" size="50" id = "n1" name="fName1" readonly>
<input type="button" value ="Clear" onclick=";document.main_fm.upLoad1.value='';document.main_fm.fName1.value='';document.getElementById('image1').src='';document.getElementById('image1').style.display='none'">
</div>
<div style='position:absolute; left:500px; top:262px' >
<img height='160' width='160' id="image1" style='display:none' />
</div>
<div style='position:absolute; left:40px; top:440px' >
<b>Second image:</b><br />
<input type="file" size="50" name="upLoad2" onchange="showImg2()"><br />
<input type="text" size="50" name="fName2" readonly>
<input type="button" value ="Clear" onclick=";document.main_fm.upLoad2.value='';document.main_fm.fName2.value='';document.getElementById('image2').src='';document.getElementById('image2').style.display='none'">
</div>
<div style='position:absolute; left:500px; top:382px' >
<img height='160' width='160' id="image2" style='display:none' />
</div>
<div style='position:absolute; left:40px; top:560px' >
<b>Third image:</b><br />
<input type="file" size="50" name="upLoad3" onchange="showImg3()"><br />
<input type="text" size="50" name="fName3" readonly>
<input type="button" value ="Clear" onclick=";document.main_fm.upLoad3.value='';document.main_fm.fName3.value='';document.getElementById('image3').src='';document.getElementById('image3').style.display='none'">
</div>
<div style='position:absolute; left:500px; top:502px' >
<img height='160' width='160' id="image3" style='display:none' />
</div>
<div style='position:absolute; left:40px; top:680px' >
<b>Forth image:</b><br />
<input type="file" size="50" name="upLoad4" onchange="showImg4()"><br />
<input type="text" size="50" name="fName4" readonly>
<input type="button" value ="Clear" onclick=";document.main_fm.upLoad4.value='';document.main_fm.fName4.value='';document.getElementById('image4').src='';document.getElementById('image4').style.display='none'">
</div>
<div style='position:absolute; left:500px; top:622px' >
<img height='160' width='160' id="image4" style='display:none' />
</div>
<div style='position:absolute; left:40px; top:800px' >
<b>Fifth image:</b><br />
<input type="file" size="50" name="upLoad5" onchange="showImg5()"><br />
<input type="text" size="50" name="fName5" readonly>
<input type="button" value ="Clear" onclick=";document.main_fm.upLoad5.value='';document.main_fm.fName5.value='';document.getElementById('image5').src='';document.getElementById('image5').style.display='none'">
</div>
<div style='position:absolute; left:500px; top:742px' >
<img height='160' width='160' id="image5" style='display:none' />
</div>
<div style='position:absolute; left:370px; top:280px' >
<input type="submit" value="Upload All Images">
</div>
</form>
</body>
</html>[/code]
[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- Using a linked stylesheet -->
<link rel="STYLESHEET" type="text/css" href="yodbod.css">
<script type="text/javascript">
var IE = (navigator.appName == "Microsoft Internet Explorer");
//
function showImage(f, idx){
var fullName = f.elements["upLoad"+idx].value;
var fileName = fullName.match(/[^/\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
{
f.elements["fName"+idx].value = 'Picture file name: '+fileName;
if (IE)
{
document.images["image"+idx].style.display = '';
document.images["image"+idx].src = fullName;
}
}
else
{
alert('Invalid file type');
return false;
}
return true;
}
function clearImage(f, idx) {
f.elements["upLoad"+idx].value='';
f.elements["fName"+idx].value='';
document.images["image"+idx].src='';
document.images["image"+idx].style.display='none';
return true;
}
</script>
</head>
<body>
<img alt="header (13K)" src="flashtest1.jpg" height="130" width="920" />
<div style='width:600px; position:absolute; left:40px; top:160px' >
<b><big>Adding pictures to your advert.</big></b><br>
<b>Select your picture files from your computer using the browse buttons.</b><br />
You can have up to five photos for all catagories except Jobs and Careers<br />
which excepts only one (we couldn't see any reason for more!).<br />
</div>
<form name="main_fm" enctype ="multipart/form-data" action="a_picts.php" method="POST">
<input type="hidden" name="run" value="on">
<input type="hidden" name="MAX FILE SIZE" value="500000">
<input type="hidden" name="adref" value="<?php echo $A_ref ?>">
<div style='position:absolute; left:40px; top:320px' >
<b>First image:</b><br />
<input type="file" size="50" name="upLoad1" onchange="return showImage(this.form, 1)"><br />
<input type="text" size="50" name="fName1" readonly>
<input type="button" value="Clear" onclick="return clearImage(this.form, 1)">
</div>
<div style='position:absolute; left:500px; top:262px' >
<img height='160' width='160' name="image1" style='display:none' />
</div>
<div style='position:absolute; left:40px; top:440px' >
<b>Second image:</b><br />
<input type="file" size="50" name="upLoad2" onchange="return showImage(this.form, 2)"><br />
<input type="text" size="50" name="fName2" readonly>
<input type="button" value="Clear" onclick="return clearImage(this.form, 2)">
</div>
<div style='position:absolute; left:500px; top:382px' >
<img height='160' width='160' name="image2" style='display:none' />
</div>
<div style='position:absolute; left:40px; top:560px' >
<b>Third image:</b><br />
<input type="file" size="50" name="upLoad3" onchange="return showImage(this.form, 3)"><br />
<input type="text" size="50" name="fName3" readonly>
<input type="button" value="Clear" onclick="return clearImage(this.form, 3)">
</div>
<div style='position:absolute; left:500px; top:502px' >
<img height='160' width='160' name="image3" style='display:none' />
</div>
<div style='position:absolute; left:40px; top:680px' >
<b>Forth image:</b><br />
<input type="file" size="50" name="upLoad4" onchange="return showImage(this.form, 4)"><br />
<input type="text" size="50" name="fName4" readonly>
<input type="button" value="Clear" onclick="return clearImage(this.form, 4)">
</div>
<div style='position:absolute; left:500px; top:622px' >
<img height='160' width='160' name="image4" style='display:none' />
</div>
<div style='position:absolute; left:40px; top:800px' >
<b>Fifth image:</b><br />
<input type="file" size="50" name="upLoad5" onchange="return showImage(this.form, 5)"><br />
<input type="text" size="50" name="fName5" readonly>
<input type="button" value="Clear" onclick="return clearImage(this.form, 5)">
</div>
<div style='position:absolute; left:500px; top:742px' >
<img height='160' width='160' name="image5" style='display:none' />
</div>
<div style='position:absolute; left:370px; top:280px' >
<input type="submit" value="Upload All Images">
</div>
</form>
</body>
</html>[/code]
0.1.9 — BETA 5.4