Forum Moderators: open
I am just a novice and really could use some friendly help :)
Thanks in advance...
G
[edited by: whoisgregg at 2:46 am (utc) on Sep. 30, 2009]
[edit reason] Whoops, no URLs please. See TOS [webmasterworld.com] :) [/edit]
<div id="mtaf-container">
<div id="mtaf-title">Send To A Friend:</div>
<form id="mtaf-form">
<p>
<label id="mtaf-box-from-label" for="mtaf-box-from">Your email goes here.</label>
<input id="mtaf-box-from" def="1" type="text" size="10" name="sendfrom" class="required email" />
</p>
<p>
<label id="mtaf-box-label" for="mtaf-box">Your friend's email goes here.</label>
<input id="mtaf-box" def="1" type="text" size="10" name="sendto" class="required email" />
</p>
<p>
<input id="mtaf-send" type="submit" value="Send" />
<input id="mtaf-cancel" type="button" value="Cancel" />
</p>
</form>
<div id="mtaf-errors"></div>
</div>
<script type="text/javascript" src="/js/thickbox.js"></script>
<link rel="stylesheet" type="text/css" href="/css/thickbox_mtaf.css" />
<script type="text/javascript" src="/js/jquery.infieldlabel.min.js"></script>
<script type="text/javascript">
$(document).ready(setup_mtaf);
</script>
<script type="text/javascript">
$(document).ready(function() {
recapture();
});
</script>
<script type="text/javascript">
$(document).ready(
function () {
pingcount=0;
pingTime = new Date();
window.setInterval("keepMeAliveLanding()", 60000);
}
);
</script>
I believe the cooresponding JS is in a file called "flare.js" and the section for MTAF is:
function sendToFriend() {
sendFrom = $('#mtaf-box-from').val();
sendTo = $("#mtaf-box").val();
if(!validateEmail(sendFrom) ¦¦ !validateEmail(sendTo)) {
$('#mtaf-errors').html('Please complete the form before sending.');
return false;
}
$('#mtaf-cancel').hide();
$('#mtaf-send').val('Sending...').attr('disabled','true');
$.ajax(
{
type: "POST",
url: "ajax-email/",
data: "sendto=" + sendTo + "&sendfrom=" + sendFrom,
success: function () {
hide_mtaf();
$("#mtaf").html("• Message sent to " + sendTo);
$("#mtaf").css("font-style","italic");
}
}
);
return false;
}
function setup_mtaf() {
$("#mtaf-form label").inFieldLabels();
$("#mtaf-form").submit(sendToFriend);
$("#mtaf-cancel").click(hide_mtaf);
$("#mtaf-box, #mtaf-box-from").focus(function() {
if ($(this).attr("def") == "1") {
$(this).val("");
$(this).attr("def","0");
}
$('#mtaf-errors').html('');
});
$("#mtaf-form").validate();
}
function show_mtaf() {
tb_show('', '#TB_inline?height=220&width=450&inlineId=mtaf-container&modal=true', null);
return false;
}
function hide_mtaf() {
$('#TB_ajaxContent form')[0].reset();
$('#mtaf-box-from, #mtaf-box').blur();
$('#mtaf-form label.error').hide();
tb_remove();
return false;
}
This is all I that I have so far... My objective is to have the "send" initate an email sent with a link back to my site, and a breif description of the product; and if possible, a DB (SQL) record of those forwards. I am hosted on a Windows server with godaddy. Thanks again to anyone who has the patience to help me :)
being able to have a simple form
That code is NOT simple. You are dealing with jQuery more than "javascript" and appears to be a custom version of the jQuery library:
<script type="text/javascript" src="/js/jquery.infieldlabel.min.js"></script>
(which I beleive is for the "in field label" jQuery form add-on from: [fuelyourcoding.com...] -- that code makes your form labels appear within their respective data input field, again NOT "simple" and really just a toy unless you have a specific need). Anyway, it isn't standard issue jQuery code and adds another layer of complexity to your page.
I suggest getting a standard install of jQuery and eliminating the "extras" and getting the basic Ajax function to work.
Big Suggestion! --- use the FireFox browser and install the Firebug add-on, that will let you debug your code.
It would be a shame if a closing bracket, semi-colon or other common error is the problem and you are pulling out hair looking for something more complicated.
Just guessing but:
$(document).ready(setup_mtaf);
doesn't look right, and seems to be what initializes or "sets up" the rest of it. Maybe it should be:
$(document).ready( function() { setup_mtaf(); });
Also, you have multiple "document ready (functions)" in script tags -- you really only need one (in the <head> section of your page), and can list the various function in proper sequence within that construct:
<script type="text/javascript">
$(document).ready(
//
// jQuery calls here
//
);
</script>
..anyway, look into jQuery, "infield" and use Firebug -- that will give you a lot of insight into what's happening.