All pastes #951705 Raw Edit

Nomikos

public text v1 · immutable
·published 2008-03-21 16:33 UTC
rendered paste body
<html>
<head>
<title>Testing</title>
<style type='text/css'>
body {
  background: white;
  font-family: verdana;
  font-size: 12px;
}
</style>
<script type='text/javascript'>
files = 0;

function addfile() {
  files++; // used as identifier for new elements
  p = document.getElementById('files');
  l = document.getElementById('addAttach');
  d = document.createElement('div');
  d.setAttribute('id', 'filediv'+files);
  d.innerHTML = " <input type='file' name='file"+files+"' id='file"+files+"'>";
  d.innerHTML += " <a href=\"javascript:removefile("+files+");\">remove</a><br>\n";
  p.insertBefore(d, l);
  if (p.getElementsByTagName('input').length == 1) l.innerHTML = 'Attach another file';
}

function removefile(id) {
  p = document.getElementById('files');
  p.removeChild(document.getElementById('filediv'+id));
  if (p.getElementsByTagName('input').length == 0) l.innerHTML = 'Attach a file';
}

</script>
</head>

<body>

<form action='$me' method='post' enctype='multipart/form-data'>
  <div id='files'>
  <a href="javascript:addfile();" id='addAttach'>Attach a file</a><br>
  </div>
  
  <input type='submit' name='submit' value='Upload' />
  </form>

</body>
</html>