Oh sorry, I have not used scott's script for a while, here's what you do:
1. Go to line 577 of phMailer.php
2.
Replace:
Code:
<?For($i=1;$i <= $allowattach; $i++) {?>
<tr>
<td width="30%" class="table_body">Attach File:</td>
<td width="70%" class="table_body"><input name="attachment[]" type="file" size="30" /></td>
</tr>
<?}?>
With:
Code:
<tr>
<td width="30%" class="table_body">Attach File:</td>
<td width="70%" class="table_body"><div id="attachmentdiv"><input name="attachment[]" type="file" size="30" /></div>
</td>
</tr>
<tr>
<td colspan="2" class="table_body"><input type="button" value="Add Another Attachment" id="addextraattach" />
</td>
</tr>
3. Replace code starting on 486
Code:
<script type="text/javascript">
var error="";
e_regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
function Checkit(theform) {
if(theform.yourname.value=="") {
error+="You did not enter your name\n";
}
if(theform.youremail.value=="") {
error+="You did not enter your email\n";
} else if(!e_regex.test(theform.youremail.value)) {
error+="Invalid email address\n";
}
if(theform.yourmessage.value=="") {
error+="You did not enter your message\n";
}
if(error) {
alert('**The form returned the following errors:**\n\n' + error);
error="";
return false;
} else {
return true;
}
}
</script>
With this:
Code:
<script type="text/javascript">
var error="";
e_regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
function Checkit(theform) {
if(theform.yourname.value=="") {
error+="You did not enter your name\n";
}
if(theform.youremail.value=="") {
error+="You did not enter your email\n";
} else if(!e_regex.test(theform.youremail.value)) {
error+="Invalid email address\n";
}
if(theform.yourmessage.value=="") {
error+="You did not enter your message\n";
}
if(error) {
alert('**The form returned the following errors:**\n\n' + error);
error="";
return false;
} else {
return true;
}
}
function init()
{
var attachbutton = document.getElementById("addextraattach");
if (attachbutton)
{
attachbutton.onclick = addField;
}
}
function addField()
{
allowedFiles = <?php echo $allowattach;?> ;
if (!addField.count)
{
addField.count = 1;
}
else
{
addField.count++;
}
if (addField.count < allowedFiles)
{
var boxDiv = document.createElement("div");
var box = document.createElement("input");
box.type = "file";
box.name = "attachment[]";
box.size = "30";
boxDiv.appendChild(box);
var attachments = document.getElementById("attachmentdiv");
if (attachments)
{
attachments.appendChild(boxDiv);
}
}
else
{
alert("You can only add "+allowedFiles+" files!");
}
}
window.onload = init;
</script>
And you should be good to go.