Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forms 2

Status
Not open for further replies.

Dipti

Programmer
Mar 28, 2001
11
US
I am making an online form for my company. the form lists all the managers name when we use the drop down menu. i want to validate my form in such a way that if i click the managers name the form should ve emailed or submitted to that email address. how can i set this up using javascript? please help.
 
If you are submitting via e-mail, you will get prompted about security bla-bla-bla, is this alright?

So to do it - set up your selet box with the addresses contained as values for the entries. Then onChange, or some other event if you wish - you just need to alter the action attribute for the form - or you can call this function:

function sendMail(Obj_form){

var select = form.selectName;

// Get address from select box
var address = select.options[select.selectedIndex].value;

if(address =="select recipient"){
alert("invalid recipient - Please choose again.")
}
else{
// set new action for the form

form.action = "mailto:" + address;

/* submit the form, if you want to perform some other stuff, leave out */

form.submit()
}
}


Use this like:

<select onChange=&quot;sendMail(this.form)&quot;..>

And to make sure the change event occurs - make sure you have an option in there saying &quot;select recipient&quot; or something - then in the function above add some clause which will display an error message if this option is selected accidentally (I will add something you can modify - it is based on the text saying &quot;select recipient&quot;)
b[sup]2[/sup] - benbiddington@surf4nix.com
 
will it make a difference if this is an intranet form which will be submitted to the respective managers? also i am using a drop down menu and i would like the managers names to appear in there and not email addresses.
 
Well I think so, I have not done much with intranet. The select still can have anything yoiu like for the text:

e.g.
<option value=&quot;boss@here.com&quot;>Hugh Jass</option>
[color]

There must be another way to submit - do you have any cgi service?
b[sup]2[/sup] - benbiddington@surf4nix.com
 
we are trying to figure this whole thing out. no one know how to get about it. I am not sure about the CGI scripting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top