I can’t my form to call a javascript function
-
Hi,
I have been pulling my hair out trying to get this to work in WordPress. I am using the Atahualpa theme.
My form takes reservation information from the user via a form and passes it to another page, which is a booking engine site.
Everything works fine with the form when I create a standalone php or html page but as soon as I copy the form into WordPress, it doesn’t work. This all hinges on a javascript call that concatenates the date fields into a format that the booking engine can read, which is yyyymmdd. The actual input on the form is done through three separate dropdown menus.
I use onSubmit=”combDep(), combRet()” to call the JS functions in the form tag. They are departure and return dates. My JS looks like this:
<script type=”text/javascript”>
<!–
function combDep()
{
var dyear = document.forms[0].d_y.value;
var dmonth = document.forms[0].d_m.value;
var dday = document.forms[0].d_d.value;
document.forms[0].DepartDate.value = dyear + dmonth + dday;
}
function combRet()
{
var ryear = document.forms[0].d_y2.value;
var rmonth = document.forms[0].d_m2.value;
var rday = document.forms[0].d_d2.value;
document.forms[0].ReturnDate.value = ryear + rmonth + rday;
}
//–></script>I have tried all different combinations of plugins and calling the JS external file in the header, putting the JS in the form, etc and nothing seems to work. I installed the ‘AYB Javascript in Posts’ plugin and that is showing some promise because it can display simple JS code, but still can’t get the form to work. Any help would be greatly appreciated.
The site is: http://islandair.server304.com/hawaii/
Thanks,
Hugh
The topic ‘I can’t my form to call a javascript function’ is closed to new replies.