killay Posted April 17, 2007 Share Posted April 17, 2007 Hi,I made a form (contact page) where people could contact the webmaster. But what I would like to do is including a checkbox to choose between 2 persons (person 1 or person 2) to contact with the same form.So for example when you create a form you have this: <form action="mailto:my@email.be" method="post" id="verzendform" enctype="text/plain" onsubmit="return check_form(this);"> But when you choose person 1 the "action" should change to person1@email.com, and if you choose person 2 it should be person2@email.com.Is that possible in one way or another? (i have to keep the same form!)Thx in advance Link to comment Share on other sites More sharing options...
aspnetguy Posted April 17, 2007 Share Posted April 17, 2007 HTML ...<form action="mailto:person1@email.be" method="post" id="verzendform" enctype="text/plain" onsubmit="return check_form(this);"><input type="check" id="myCheck" onclick="changeEmail(this)"/></form> JS function changeEmail(chk){ var frm = document.getElementById("verzendform"); if(chk.checked) frm.action = "mailto:person2@email.be"; else frm.action = "mailto:person1@email.be";} Link to comment Share on other sites More sharing options...
killay Posted April 17, 2007 Author Share Posted April 17, 2007 I dont get any radiobutton with this script... are you sure this is well written???this is the whole page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl"><head> <meta name="author" content="Peter Vercauteren 1 TINA" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="Gamcenter" /> <meta name="keywords" content="Gamecenter" /><title>Welkom :: index</title><link rel="stylesheet" type="text/css" href="mijnstijlen.css" /> <script type="text/javascript"> function check_form(form) { var errormsg = "Gelieve volgende velden in te vullen:\n\n"; var error = false; var form = document.getElementById("verzendform"); var familienaam = document.getElementById("familienaam"); var voornaam = document.getElementById("voornaam"); var email = document.getElementById("email"); var vragenopmerkingen = document.getElementById("vragenopmerkingen"); if (voornaam.value == "") { errormsg += "Voornaam.\n"; error = true; } if (familienaam.value == "") { errormsg += "Familienaam.\n"; error = true; } if (email.value == "" || !email_check(email.value)) { errormsg += "E-mail / Ongeldige email.\n"; error = true; } if (vragenopmerkingen.value == "") { errormsg += "Vragen / Opmerkingen.\n"; error = true; } if (error) { window.alert(errormsg); return false; } return true; } function email_check(email) { if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) { return true; } else { return false; } } </script></head><body> <div id="bg"> <div id="container"> <div id="headerhome"> <div id="navcontainer1"> <ul id="navlist1"> <li><a href="webmaster.html">Webmaster</a></li> <li><a href="contact.html">Contact</a></li> <li><a href="info.html">Info</a></li> <li><a href="gallerij.html">Gallerij</a></li> <li><a href="index.html">Home</a></li> </ul> </div> </div> <div id="rechtscontent2"> <br /> <h1>Contact</h1> <div id="kolom1"> <form action="mailto:****@gmail.be" method="post" id="verzendform" enctype="text/plain" onsubmit="return check_form(this);"> <p> Voornaam:<br /><input type="text" size="40" id="voornaam" name="voornaam"></input><br /> Familienaam:<br /><input type="text" size="40" id="familienaam" name="familienaam"></input><br /> E-mail:<br /><input type="text" size="40" id="email" name="email"></input><br /> Vragen / Opmerkingen:<br /><textarea id="vragenopmerkingen" name="vragenopmerkingen" rows="5" cols="37"></textarea><br /> </p> <p> <input class="knop" type="submit" value="Verzenden "></input> <input class="knop" type="reset" value="Herstellen"></input> </p> </form> </div> <br /> </div> <div id="footer"> <div id="textfooter"> Peter Vercauteren © <span class="footercirkel">•</span> **** <span class="footercirkel">•</span> **** <span class="footercirkel">•</span> Tel.:**** <span class="footercirkel">•</span> E-mail: <a href="mailto:****@gmail.com">****@gmail.com</a> </div> </div> </div></body></html> Link to comment Share on other sites More sharing options...
vytas Posted April 17, 2007 Share Posted April 17, 2007 well if you want a radio button use.<input type='radio'> Link to comment Share on other sites More sharing options...
aspnetguy Posted April 17, 2007 Share Posted April 17, 2007 I dont get any radiobutton with this script... are you sure this is well written???I didn't use a radiobutton I used a check box. You asked how to change the form action using a check box.a checkbox to choose between 2 persons (person 1 or person 2) to contact with the same form Link to comment Share on other sites More sharing options...
killay Posted April 17, 2007 Author Share Posted April 17, 2007 i knwo that but could you please edit my code so you get 2 radiobuttons (if you click on the first one you get person1 email adres if you click on the second radiobutton you get person2 email adress in outlook)cause if I type this: <input type="radio" id="myCheck" value="webmaster"onclick="changeEmail(this)"/>Webmaster<input type="radio" id="myCheck" value="oupost"onclick="changeEmail(this)"/>De Oupost it doesnt work... so please edit it fully thx in advance Link to comment Share on other sites More sharing options...
killay Posted April 18, 2007 Author Share Posted April 18, 2007 I didn't use a radiobutton I used a check box. You asked how to change the form action using a check box.I made a mistake cause i was kind in a hurry, sorry for that. I was desperate cause i need gto finish this site in a week.My english isn't that good either thats why i make sometimes mistakes.greetz Link to comment Share on other sites More sharing options...
killay Posted April 19, 2007 Author Share Posted April 19, 2007 isn't there anyone who can help me? Link to comment Share on other sites More sharing options...
aspnetguy Posted April 20, 2007 Share Posted April 20, 2007 HTML <form id="theForm" action="mailto:person1@domain.com" method="post"><input type="radio" name="email" value="person1@domain.com" selected="selected" onclick="changeEmail(this)"/> person1<br/><input type="radio" name="email" value="person2@domain.com" onclick="changeEmail(this)"/> person2</form> JS function changeEmail(radio){ document.getElementById("theForm").action = radio.value;} Link to comment Share on other sites More sharing options...
killay Posted April 21, 2007 Author Share Posted April 21, 2007 thx, it works almost The email changes but only in the adress bar --> "http://www.site.com/person1@domain.com" or "http://www.site.com/person2@domain.com"So it doesnt really recognize the mailto: action. Link to comment Share on other sites More sharing options...
killay Posted April 24, 2007 Author Share Posted April 24, 2007 someone knows? Link to comment Share on other sites More sharing options...
pulpfiction Posted April 24, 2007 Share Posted April 24, 2007 small change.... add "mailto:" to the radio button value.....<form id="theForm" action="mailto:person1@domain.com" method="post"><input type="radio" name="email" value="mailto:person1@domain.com" selected="selected" onclick="changeEmail(this)"/> person1<br/><input type="radio" name="email" value="mailto:person2@domain.com" onclick="changeEmail(this)"/> person2</form> Link to comment Share on other sites More sharing options...
aspnetguy Posted April 24, 2007 Share Posted April 24, 2007 lol, oops, sorry about that. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now