|
-
Jun 6th, 2011, 10:17 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Using javascript to submit a form
I've made an instant quote calculator where you can book online. I have used a number of div elements with text fields because there's a lot of information to collect when booking. When the user has finished filling it in and clicks submit, i use javascript to fill in the form below. As the user clicks submit within one of my div elements and not the button on the form, i need to use javascript to 'click' submit. I did some searching on the web and found this ' document.forms["MyForm"].submit() ', but when using the code i get an error 'object does not support this property or method'.
Thanks in advance, Chris1990
My javascript code:
Code:
function SendEmail() {
BookingTitleName = document.getElementById('TitleName').value
BookingFirstName = document.getElementById('FirstName').value
BookingLastName = document.getElementById('LastName').value
BookingEmail = document.getElementById('EmailAddress').value
BookingPhone = document.getElementById('MobilePhone').value
document.getElementById('post_fullname').value = BookingTitleName + " " + BookingFirstName + " " + BookingLastName;
document.getElementById('post_email').value = BookingEmail;
document.getElementById('post_phone').value = BookingPhone;
document.forms["onlinebooking"].submit();
}
My form:
Code:
<form action="processor.php" enctype="multipart/form-data" method="post" name=
"onlinebooking" id="onlinebooking" >
<input id="post_fullname" name="post_fullname" type=
"text" maxlength="255" value="" />
<input id="post_email" name="post_fullname" type=
"text" maxlength="255" value="" />
<input id="post_phone" name="post_fullname" type=
"text" maxlength="255" value="" />
<textarea id="post_fulladdress" name="post_fulladdress"></textarea>
<input id="post_fullname" name="post_fulldate" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_fulltime" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_fullstart" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_fulldestination" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_vehicletype" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_fullpassengers" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_flightno" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_specialreq" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_distance" type=
"text" maxlength="255" value="" />
<input id="post_fullname" name="post_fare" type=
"text" maxlength="255" value="" />
<input type="hidden" name="form_id" value="onlinebooking" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</form>
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|