PDA

View Full Version : html problem


bassman
05-03-2009, 10:00 PM
HELLOOOOOO PC GUIDE!!!!! :D
My goodness, where does the time go? OK, I have a code/language problem and I need a new direction. I have built a complete site for my friends off road race track. On the site is a preregistration form. I want racers to fill in this form and then submit it so that we can create a registered list to plan several things along with making check-in easier. I wrote it all in simple html and am trying to use "mailto" and as we all know, it fails in IE :mad: I have looked and looked for fixes for my existing code but alas, it will not work.
I need a suggestion as to how to perform this function better. it is not necessary to get this info via e-mail, but I don't know anything else to do.
If anyone wants to look over my code you can see it HERE (http://ocorr.net/register.html) but I think I am ready for something completely different.

I did happen to look over some other code (in html) but I don't know what happens to the output.

Any help brings much love and thanks ;)

Ajmukon
05-03-2009, 10:05 PM
What isn't working?

I looked at the source, it appears fine to me...

bassman
05-03-2009, 10:15 PM
Ahh. Forgot to mention that part:rolleyes:
From Firefox, when you hit the register button, it produces an e-mail with a subject and all the input info from the form. From IE it produces a blank e-mail with only the "To" addresses. Since most of our users are on IE, this is a failure.

Paul Komski
05-04-2009, 05:51 AM
I think part of the problem is that when you use Action from your form to run the mailto: is that IE will (by default anyway) attempt to actually send the mail rather than just display it in the default email client. Firefox just opens the client. This might be capable of being modified in the registry but that would be a real pain for users.

I have written you a javascript that should do what you want because it defines the whole mailto: string. I hope I have written enough of it to let you modify the remainder. Note in particular that the email adresses have deliberately had the name and domain set as different variables and which are only recombined when the button is clicked. This munges the mail addresses so that spambots don't lift the addresses off the web-page.

It's possible there is a limit to the number of characters that the whole mailto: string can utilise but, if so, it hasn't yet been reached.

I don't know how this works for those with webmail accounts. The alternative is to use a server script (cgi, php, etc) as per instructions from your web host and send the form directly from the web page.
<HTML>
<HEAD>
<TITLE>Out of Control Off Road Raceway Pre-Registration</TITLE>

<SCRIPT LANGUAGE="JavaScript">
function SendMail (form) {

var maildom = "ocorr.net";
var mail1 = "claywoods@";
var mail2 = "frank@";

var subject = "Web Form Submission.";

var race = "race="+form.race.value;
var driver_name = "driver_name="+form.driver_name.value;
var driver_phone = form.driver_phone.value;
var driver_email = form.driver_email.value;
var nick_name = form.nick_name.value;
var co_driver = form.co_driver.value;
var co_driver_phone = form.co_driver_phone.value;
var co_driver_email = form.co_driver_email.value;

var body_message = race+"%0D"+driver_name+"%0D"+driver_phone+"%0D"+driver_email+"%0D"+nick_name+"%0D"+co_driver+"%0D"+co_driver_phone+"%0D"+co_driver_email;

var mailto_link = 'mailto:'+mail1+maildom+","+mail2+maildom+"?subject="+subject+"&body="+body_message;

win = window.open(mailto_link,'emailWindow');
if (win && win.open &&!win.closed) win.close();
}
</SCRIPT>
</HEAD>

<BODY>
<FORM NAME="myform" ACTION="" METHOD="GET">
<H1>ENTER DETAILS FOR EMAIL:</H1>

<p>
Race date and Classes:<select name="race" size="1">
<option>May 16. RWB, Stock bug, UTV stock, UTV open, 8, 7, 7s, Trophy cart</option>
<option>May 23. UTV National Championship $10,000.00 TO WIN!</option></select>
</p>

<p>
Driver Name:<input type="text" name="driver_name"> &nbsp; &nbsp; Phone #:<input type="text"
name="driver_phone"> &nbsp; &nbsp; E-mail:<input type="text" name="driver_email">
</p>

<p>
Nick Name:<input type="text" name="nick_name">
</p>

<p>
Co-Driver Name:<input type="text" name="co_driver"> &nbsp; &nbsp; Phone #:<input type="text"
name="co_driver_phone"> &nbsp; &nbsp; E-mail:<input type="text" name="co_driver_email">
</p>


<P><INPUT TYPE="button" NAME="button" Value="Prepare Default EMail" onClick="SendMail(this.form)">&nbsp; &nbsp; <input type="reset" Value="Reset Values"></P>
</FORM>
</BODY>
</HTML>

bassman
05-04-2009, 11:45 AM
WOW!!!! That is so awesome Paul. Once again you are my code hero ;)
I can see what needs to be done to finish this.

THANK YOU THANK YOU THANK YOU:cool:

bassman
05-05-2009, 12:55 AM
Boy, what a pain in the cheeks :eek:
OK, I went round and round with this code, got it all modified to work on the page, testing one line at a time until I was satisfied I had a handle on it, copied and pasted a bunch of stuff to finish up and IE failed it again. Turned the comp off cause I was getting :mad:
Came back to it tonight and figured out that I had one item named "class". Changed it to "car_class" and it would work, except that none of my drop downs return data. Just tried your original code and it is the same.
Any ideas on that?

Thanks again soooo much!!!:cool:

EDIT It does work in FF but not IE

Paul Komski
05-05-2009, 02:37 AM
I had obviously missed that the selection of an option group doesnt work in IE. The fix is to use an id and not a name in the markup for the tag in question. Then use that id to generate a selectedIndex value for the javascript. Basically:-

Race date and Classes:<select name="race" size="1">
becomes
Race date and Classes:<select name="race" id="raceid" size="1">

and the single line

var race = "race="+form.race.value;
becomes
var s = document.getElementById("raceid");
var race = "race="+s.options[s.selectedIndex].text;

bassman
05-05-2009, 01:17 PM
Everything is working great. You are my savior Paul. What can I do for you my friend ;)

Paul Komski
05-05-2009, 03:28 PM
What can I do for you my friend
Catch a bass and have a beer (or two)!