PDA

View Full Version : Modify script



terkini
11-01-2006, 07:04 AM
Hi Guys,
I have the following script from www.javascripts.internet.com (Copyright acknowledged) which I would like to modify:

<HEAD>
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function mailsome1(){
who=prompt("Enter recipient's email address: ","antispammer@earthling.net");
what=prompt("Enter the subject: ","none");
if (confirm("Are you sure you want to mail "+who+" with the subject of "+what+"?")==true){
parent.location.href='mailto:'+who+'?subject='+what+'';
}
}
// End -->
</SCRIPT>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<CENTER>
<a href='javascript:mailsome1()'>E-Mail Someone!</a>
<FORM>
<input type=button value="E-Mail Someone!" onClick="mailsome1()">
</FORM>
</CENTER>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.02 KB -->

As you can see, in the above script, the user is free to write any email address or anything on the form. I would like to modify the mode of entry (from textarea) into "dropdown" method i.e. user select the email addresses and the subject matters from a dropdown list. Can anybody here help me to modify the script.
Another thing is that, is it also possible to make a dropdown selection for the body of the email (i.e. user select the body/content of their email from a dropdown selection).

Thank you

jscheuer1
11-01-2006, 07:27 AM
Not really worth it as, this script only calls the user's configured email client (if any). Once that happens, the user can change anything about the message to whatever he or she wishes.

A server side mail form from your host or third party server side mail form should be used. What exactly is this for?

tech_support
11-02-2006, 06:11 AM
You don't need to keep the copyright notice.

jscheuer1
11-02-2006, 09:22 AM
You don't need to keep the copyright notice.

Let's not start encouraging folks to drop that. Even if that particular site doesn't require it, (which I know nothing about - one way or the other) it is a nice courtesy to include it.

tech_support
11-02-2006, 09:23 AM
It doesn't state something like 'This notice must stay intact for legal use' so I guess it's perfectly legal to use it without credit.

jscheuer1
11-02-2006, 09:28 AM
It doesn't state something like 'This notice must stay intact for legal use' so I guess it's perfectly legal to use it without credit.

Not really, you would have to go to the site and read their use policy, if any, to determine that. Don't just assume because it isn't on the notice itself that it isn't a part of the site's use policy. Also, even if it isn't required, it is still a courtesy to include it.

tech_support
11-02-2006, 09:33 AM
After browsing the site, I got to this:



Yes, we offer our site as a free "public service" resource. Simply stated, all the scripts on this site are free for personal or business use. The only requirement for use of archives is that you leave the credit information inside the script. We also don't think it's too much to ask if you would please link back to The JavaScript Source site to help spread the word about our site. The address for linking to The JavaScript Source is:

http://javascript.internet.com

Thanks! And, more information about linking to us is available at:

http://javascript.internet.com/link-us.html

Ok. Sorry 'bout that :)

terkini
11-03-2006, 09:43 AM
It doesn't really matter that user can change the subject matter or body of the email as most of the "users" are my students (btw, I am a teacher). I intend to put it on my website for our convenience, for example, they may send an email to confirm that they have send in their assignments or to request for extension of time to submit their assignment or to request to change classes or join another class.
Is it possible to modify the script? Pls help me.

jscheuer1
11-03-2006, 11:16 AM
<form action="#" method="post">
<select onchange="if(this.selectedIndex>0){this.form.action='mailto:someone@some.com?subject='+this.options[this.selectedIndex].value;this.form.submit();}">
<option selected value="">Select</option>
<option value="Homework">Homework</option>
<option value="Assignment">Assignment</option>
</select>
</form>

Substitute your email address for the red place holder. The green value attributes become the subject. You can use 'text' instead of 'value' here:


subject='+this.options[this.selectedIndex].value;

And the subject will be the text that is shown. This eliminates the need to write everything twice as the value attributes can then be dropped. But, you might want one thing as the selection and another as the subject, in which case retain the value attribute and syntax as is.

This all could be done more simply, without even javascript:


<form action="mailto:someone@some.com">
<select name="subject">
<option selected value="">Select</option>
<option value="Homework">Homework</option>
<option value="Assignment">Assignment</option>
</select><br>
<input type="submit" value="submit">
</form>

But, Opera will not use the subject (IE and FF were fine with this though, if using OE) and you could end up with the subject as 'Select' in any browser.

I still think a server side solution (as I mentioned before, they are not hard to set up) would be better as, even with no mail client configured, your students could still send the mail. This may be more common than you think what with so many younger folks using hotmail and yahoomail, etc. These type of web based email services do not require (or in most cases allow) one to use a configured email client. As a result, many folks who use them do not bother to configure an email client or, they are using someone else's computer that has an email client setup but, for the owner of the computer, not for them. Computers in libraries typically have no email client configured.

thompa
03-07-2007, 02:41 PM
John,
I maintain a web site on the 'free' web space that is made available by the cable supplier. They don't have CGI or PHP available to use for server side email... is it possible to still use a server side email application in these circumstances? If not, can you recommend another approach - or other free sites that might be used?
Allan

jscheuer1
03-07-2007, 04:27 PM
John,
I maintain a web site on the 'free' web space that is made available by the cable supplier. They don't have CGI or PHP available to use for server side email... is it possible to still use a server side email application in these circumstances? If not, can you recommend another approach - or other free sites that might be used?
Allan

You can still use a third party server-side mail form. It has been awhile since I looked into these things but, last I checked using Google there were plenty around:

http://www.google.com/search?hl=en&q=free+mail+form&btnG=Search

There are also a number of free hosts available but, one would need to check their terms to see if they provide suitable services, many do. Here's one that others have recommended:

http://www.mixcat.net/

I have no direct experience with them though. My experience with hosts is limited to what you have (free via my ISP) plus the work I do for folks who have paid hosts.