Click to See Complete Forum and Search --> : want to send this info to my email


tane
08-06-2004, 09:42 PM
I have script that i was given that lets the users of my site select the songs they want ......my question is I want to add a button that sends this info(the songs they have choosen to my email but not sure how to do it below is the script that i am using........


<html>
<head>
<title>Test</title>
<script type="text/javascript">

function songsChosen(){
var es = document.getElementById('choosesongs_form').elements;
var l = '';
for(var i = 0; i < es.length; i++){
if(es[i].tagName.toLowerCase() == 'input' && es[i].type.toLowerCase() == 'checkbox' && es[i].checked){
l += '<'+'li>'+es[i].value+'<\/li>';
}
}
document.getElementById('choosesongs').style.display = 'none';
document.getElementById('viewsongs').style.display = '';
document.getElementById('viewsongs_list').innerHTML = l;
}

function backToOptions(){
document.getElementById('viewsongs').style.display = 'none';
document.getElementById('choosesongs').style.display = '';
}

</script>
</head>
<body>

<div id="choosesongs">
<h1>Choose songs</h1>
<p>Choose the songs you want:</p>

<form id="choosesongs_form" action="" method="post" onsubmit="songsChosen(); return false;">
<p>
<input type="checkbox" value="Song name 1"> Song name 1<br>
<input type="checkbox" value="Song name 2"> Song name 2<br>
<input type="checkbox" value="Song name 3"> Song name 3
</p>
<p><input type="submit" value="Submit songs"></p>
</form>

</div>


<div id="viewsongs" style="display: none;">
<h1>You chose these songs</h1>
<p>
<input type="button" value="Print page" onclick="window.print();">
<input type="button" value="Back to options" onclick="backToOptions();">
</p>

<ul id="viewsongs_list">
<li></li>
</ul>
</div>


</body>
</html>

steelersfan88
08-06-2004, 09:53 PM
<form id="choosesongs_form" action="***" method="post" onsubmit="songsChosen(); return false;">*** - Some PHP, Perl, ASP, etc. script here.

You need server side programming for this, JS won't do.

Dr. Script

JacksonCochrane
08-07-2004, 07:48 AM
Does this help?

<html>
<head>
<title>Test</title>
<script type="text/javascript">

function songsChosen(){
var es = document.getElementById('choosesongs_form').elements;
var l = '';
for(var i = 0; i < es.length; i++){
if(es[i].tagName.toLowerCase() == 'input' && es[i].type.toLowerCase() == 'checkbox' && es[i].checked){
l += '<'+'li>'+es[i].value+'<\/li>';
}
}
document.getElementById('choosesongs').style.display = 'none';
document.getElementById('viewsongs').style.display = '';
document.getElementById('viewsongs_list').innerHTML = l;
}

function backToOptions(){
document.getElementById('viewsongs').style.display = 'none';
document.getElementById('choosesongs').style.display = '';
}

function sendMail(){

recipient = "someone@someplace.com"
isSubject = "Selected Songs"
isBody = viewsongs_list.innerText;

document.forms.Send.action = "mailto:"+recipient+"?subject="+isSubject+"&body="+isBody+".&nbsp"
}

</script>
</head>
<body>

<div id="choosesongs">
<h1>Choose songs</h1>
<p>Choose the songs you want:</p>

<form id="choosesongs_form" action="" method="post" onsubmit="songsChosen(); return false;">
<p>
<input type="checkbox" value="Song name 1"> Song name 1<br>
<input type="checkbox" value="Song name 2"> Song name 2<br>
<input type="checkbox" value="Song name 3"> Song name 3
</p>
<p><input type="submit" value="Submit songs"></p>
</form>
</div>

<div id="viewsongs" style="display: none;">
<h1>You chose these songs</h1>
<p>
<input type="button" value="Print page" onclick="window.print();">
<input type="button" value="Back to options" onclick="backToOptions();">
<form name='Send'action=''>
<input type="submit" value="Send Selections by Email" onclick="sendMail()">
</form>
</p>

<ul id="viewsongs_list">
<li></li>
</ul>
</div>
</body>
</html>

sciguyryan
08-07-2004, 11:11 AM
Actually there is no need for a script at all. the action attribute of the form tag so, just replace:
<form name='Send' action=''> with
<form name="Send" action="mailto:Username@Server.Whatever?subject=Form Sender" enctype="text/plain" method="post">

Action tells the browser to send it via E-mail,
Enctype tels it the display format and method tells it to post it and not get it (Get is used mostly in SSL).

Hope that helps.

tane
08-07-2004, 07:56 PM
thanks guys for your help............Jackson I am using your function with my script the functions works good!! but was wonder if when the songs get placed into the email is it possible to seperate them with commas or could each song go on a seperate line if tyhats possible.....thanks in advance

JacksonCochrane
08-08-2004, 05:04 AM
I fought with that exact problem. Here's the best I could do.

function sendMail(){
recipient = "someone@someplace.com"
isSubject = "Selected Songs"
toBody = viewsongs_list.innerText;
toBody = toBody.split(/[\r]/g);
isBody = toBody[0]+" ----- "+toBody[1]+" ----- "+toBody[2];
document.forms.Send.action = "mailto:"+recipient+"?subject="+isSubject+"&body="+isBody+"&nbsp"
}

This just goes ahead and "adds" the elements of an array, separating them by -------, even if the element is empty. You seem quite capable, so I'm sure you can add code to test for an empty element, and if it is, to not include it in the isBody string. I got this far with it and decided, that maybe you won't even care the way the first code I posted works, so I set it aside. So, I think this should help you along.

steelersfan88
08-08-2004, 09:40 AM
accessibility .... document.geTelementById('viewsongs_list').innerText;and also:toBody.split(/[\r]/g);I think you can make out without the red.

Dr. Script

tane
08-08-2004, 09:41 AM
thanks heaps Jackson and everyone else that has helped u have been great help......cheers Tane

JacksonCochrane
08-08-2004, 10:34 AM
What we could really do without, is the gratuitous criticism of others. It's juvenile, it's uncalled for, and is insulting. Nothing better to do on Sunday, yet, than to play with the red font? The only thing that prevents this website from being enjoyable to all, are the arrogant few, like you, who go around hunting for a place to post asinine comments in judgment of others.

steelersfan88
08-08-2004, 02:03 PM
Correction does not equal criticism. Either way, one should learn from one's mistakes, not avoid them.

^.^.^ getElementById ^.^.^ (caps prob.)

JacksonCochrane
08-08-2004, 05:55 PM
You're not my editor, or teacher, ****head. Not only are you arrrogant, you're an a**hole. A stupid little ****, a ****less little ba***rd with a big mouth. The only purpose for your behavior is to piss people off. A pair of square brackets! There are dozens of questions, thousands of lines, but on a Sunday, you decide to appoint yourself my teacher! You arrogant pig. Come to me, pussy. I'll give you my address. Come knock on my door, and I'll teach you about respect, you little punk. I'm not going take any lip from a stupid little ****. Come to me, pussy.

Moderators Note
Please refrain from using such language.
I have noticed this that you do not handle any criticism very well.If you do not like some one's response that does not give you any right to resort to such language in these forums.

I'd appreciate if you try to co-operate
Thanks
Khalid

steelersfan88
08-08-2004, 06:05 PM
If I'm wrong, please correct me, but I think the purpose of these forums are to help teach web development to people who need assistance.

I don't think your previous post has done any assistance at all to help tane with the problems he has asked us to assist him with.

Please act in the goodness of helping, and not the way you have presented yourself. You obviously are not here to help, and it makes it harder for those of us who at least are willing to try.

I leave it up to you guys.

rhsunderground
08-08-2004, 06:34 PM
Originally posted by JacksonCochrane
You're not my editor, or teacher, ****head......
.....Come to me, pussy. Those are COMPLETELY unnecessary comments and the moderators and administration here will not tolerate it.
JacksonCochrane's profile
I only respond to the AUTHOR of the threadi think you messed up on that part.

David Harrison
08-08-2004, 10:34 PM
Originally posted by steelersfan88
accessibility .... document.getElementById('viewsongs_list').innerText;This was correcting a mistake on your part.Originally posted by steelersfan88
and also:toBody.split(/[\r]/g);I think you can make out without the red.This was just a "by the way".

Chill out, don't take everything personal, since this is a help forum you can't expect people not to correct you.

JacksonCochrane
08-09-2004, 05:38 AM
Steeler;

Listen to me, you arrogant punk. I'm not the one seeking help. I'm not here to be your student. Get your damn finger out of my face. If you have something original of your own to offer, then do so, but to hunt for a pair of square brackets, just to say nah nah, look what I found has no purpose and offered the author nothing. The code works as is, with the brackets you big mouthed punk. Get out of my face. Don't ever appoint yourself my editor, don't ever appoint yourself my teacher. If you want my address, I'll give it to. If you knock on my door, I'll shut your big mouth for good. A forum doesn't give you the right to strut around acting as if you are a little king. That goes for you and your punk buddies. If you want to play a game with me, I'll show you how I play. Get out of my face.

David Harrison
08-09-2004, 07:45 AM
Well that last post wasn't from steelers, it was from me. I was trying to get you to calm down by showing you (what I assume to be) the reasoning behind what steelers posted. Obviously that hasn't worked since you are still insulting members and cruising for a bruising.

You can't carry on posting comments like this without being banned, so it seems as though you're going to have to shut your mouth.

As it seems this is just turning into a one-sided slanging match and the OP's question has been answered, I don't think it will be very long at all until this thread is locked.