Trying to adapt my working email code to work on a different page... I have VERY little javascript experience...and don't know proper syntax.
I want to put this on a page that is created with a while loop (php) and has many members on one page. So it needs a unique identifier for the form (and I think each field in the form) so it will properly update back to the correct section of the while loop (instead of just the top one like it does now.).
I appreciate your assistance.
Javascript
var thisRandNum = "<?php echo $thisRandNum; ?>";
// Start Private Messaging stuff
$('#pmForm').submit(function(){$('input[type=submit]', this).attr('disabled', 'disabled');});
function sendPM ( ) {
var pmSubject = $("#pmSubject");
var pmTextArea = $("#pmTextArea");
var sendername = $("#pm_sender_name");
var senderid = $("#pm_sender_id");
var recName = $("#pm_rec_name");
var recID = $("#pm_rec_id");
var pm_wipit = $("#pmWipit");
var url = "scripts_for_profile/private_msg_parse.php";
if (pmSubject.val() == "") {
$("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="21" height="20" /> Please type a subject.').show().fadeOut(6000);
} else if (pmTextArea.val() == "") {
$("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="21" height="20" /> Please type in your message.').show().fadeOut(6000);
} else {
$("#pmFormProcessGif").show();
$.post(url,{ subject: pmSubject.val(), email_body: pmTextArea.val(), senderName: sendername.val(), senderID: senderid.val(), rcpntName: recName.val(), rcpntID: recID.val(), thisWipit: pm_wipit.val() }, function(data) {
$("#pmForm").slideUp("fast");
$("#interactionResults").html(data).show().fadeOut(5000);
document.pmForm['. $id .'].pmTextArea.value='';
document.pmForm['. $id .'].pmSubject.value='';
$("#pmFormProcessGif").hide();
});
}
}
// End Messaging
PHP / HTML
<div class="interactContainers" id='.$id.' style="background-color: #EAF4FF;">
<table width="770" border="0" cellspacing="2" cellpadding="2">
<form action="javascript:sendPM();" name="pmForm" id='. $id .' method="post">
<tr >
<td colspan="2" align="center">
<font size="+1">Sending Private Message to <strong><em>'.$username.'</em></strong></font><br /><br />
<!-- START DIV - interaction status container that only appears when we instruct it to -->
<div id="interactionResults" ></div>
<!-- END DIV - interaction status container that only appears when we instruct it to -->
</td >
<td align="center"><font size="+1">E-mail Tips</font><br /><br /></td >
</tr>
<tr ><td align="right" valign="top" width="30px">Subject:</td>
<td width="60%" valign="top" align="left" ><input name="pmSubject" id="pmSubject" type="text" cols="50" maxlength="85" /><br></td><td width="30%" rspan="4"><div><table border="1"> </table></div></td>
</tr>
<tr><td align="right" valign="top" width="30px">Message:</td>
<td width="60%" valign="top" align="left"><textarea name="pmTextArea" id="pmTextArea" cols="55" rows="8" ></textarea></td>
</tr>
<tr><td>
<input name="pm_sender_id" id="pm_sender_id" type="hidden" value='. $_SESSION['id'] .' />
<input name="pm_sender_name" id="pm_sender_name" type="hidden" value='. $_SESSION['username'] .' />
<input name="pm_rec_id" id="pm_rec_id" type="hidden" value='. $id .' />
<input name="pm_rec_name" id="pm_rec_name" type="hidden" value='. $username .' />
<input name="pmWipit" id="pmWipit" type="hidden" value='. $thisRandNum .' />
<span name="PMStatus" style="color:#F00;"></span>
</td>
<td ></td >
</tr>
<tr>
<td width="30px"></td>
<td align="right" width="60%">
<br /><input name="pmSubmit" type="submit" value="Send" /> or <a href="#" onclick="return false" onmousedown ="javascript:toggleSlideBox('. $id .');">Close</a>
<span id="pmFormProcessGif" style="display:none;"><img src="images/loading.gif" width="28" height="10" alt="Loading" /></span></td>
</tr>
</form>
</table>
</div>
I know the '. $id . ' needs to go into the php / html sections but I am unsure the proper place to put them. I don't think this is hard...I think I am just JavaScript ignorant.