It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Mailto: multiple options

Mailto: multiple options

Postby cornerstone on Thu Oct 04, 2007 8:39 pm

Sorry I am not familiar with Javascript but I was recommended to try here with my question. I am trying to use the mailto: feature in forms but I want to be able to have an option of letting the user chose to whom
the email will be sent. Is this available in Java?

See here for my original thread:
mailto-question-vt8117.html
cornerstone
 
Posts: 6
Joined: Thu Oct 04, 2007 1:07 pm

Postby bobbyblades on Thu Oct 04, 2007 9:41 pm

you need a select<select> form element to create a dropdown list for the user to choose the recipient, then get the value of the selected option and change the action of the form to that by concatenating a string. based on the selected value.

document.forms[0].action = ("mailto:" + document.forms.selector.options[document.forms.selector.selectedIndex].value);



<select name="selector">
<option value="secretagent@cia.gov">secretagent@cia.gov</option>
</select>



I believe that should get the job done didn't check the code so there may be an error or 2


:wink:



also you do realize that mailto does not actually send an email?
User avatar
bobbyblades
50+ Club
 
Posts: 85
Joined: Fri Aug 24, 2007 8:38 pm
Location: hawaii or bust

Postby cornerstone on Fri Oct 05, 2007 2:53 pm

I don't know if that code will work because the “selector” cannot be applied to the first line of code when the page loads up because the user hasn’t had a chance to select the e-mail address yet.

I have received other opinions that"


If there is any sort of “option” to select, there needs to be an “action” to process the option. The action is usually a button… The only way I can see you doing this is have some sort of form that has a pull down menu. The pull down menu will allow you to select the e-mail recipient and the action on the form would be the mailto… see if that works.



Anybody know how to do this...? Sorry I am just a hobbiest and am learning everything through trial and error.
[/quote]
cornerstone
 
Posts: 6
Joined: Thu Oct 04, 2007 1:07 pm

Postby dafunkymunky on Fri Oct 05, 2007 3:06 pm

Hey you can never mail using HTML/Javascript, You'll need to use PHP os ASP(dont use this), So now in PHP you'll have to specify a server that'll act as a mail server(dont worry many servers are available), the recepient, and sender and there are other options also..


http://in.php.net/function.mail

this link should tell you all about it..
And its very easy to do it.
--------DAFUNKYMUNKY--------
::THE::NECESSARY::[D]EVIL::
....errr i mean munky....
User avatar
dafunkymunky
100+ Club
 
Posts: 183
Joined: Fri Apr 08, 2005 7:32 am
Location: India

Postby bobbyblades on Fri Oct 05, 2007 7:57 pm

OK go back to my first post on the page,

in the body of the html document you need a drop down select list right?

well thats what a select element is, it's a wrapper around a group of options
this should be written first

<select name="selector" onchange="changeAction()">
<option value="secretagent@cia.gov" defaultSelected="true">secretagent@cia.gov</option>
</select>


again this code should come before any code that references it in line(outside of a function)


you'll see the onchange event handler in the select element tag
which calls a function, this function will be called whenever the selection
option changes(when a new email address is selected) the function changeAction is wriiten below



<script language="javascript">

function changeAction() {
document.forms[0].action = ("mailto:" + document.forms.selector.options[document.forms.selector.selectedIndex].value);
}


</script>



again I did not test any of this, but this is the procedure you need to take
for what you are talking about doing. as for mailing the actual email look into the php mail() function
User avatar
bobbyblades
50+ Club
 
Posts: 85
Joined: Fri Aug 24, 2007 8:38 pm
Location: hawaii or bust

Postby cornerstone on Tue Oct 16, 2007 4:19 pm

Okay I understand the idea but not how to actually do it.

here is an example form, how do you add a drop down?

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<FORM METHOD="POST" ACTION="mailto:test@test.com" enctype="text/plain">
<p>1.What colour is the sky?</p>
<p>
<textarea name="1" id="1" cols="80" rows="5"></textarea>
</p>
<p>
<INPUT TYPE=submit>
<INPUT TYPE=reset>
</p>
</FORM>
</body>
</html>
cornerstone
 
Posts: 6
Joined: Thu Oct 04, 2007 1:07 pm


Who is online

Users browsing this forum: No registered users and 3 guests