I’m writing a PHP web site but need some Javascript to do a bit of extra stuff.
The main form I’m writing is a ‘wizard’ style form which allows users to enter information into the system bit by bit. Each sub-form has a ‘Next’ button to allow the user to move to the next step.
The first page contains a ‘registration/login’ page where users can enter their business details if they’ve never registered before. The next page in the chain allows them to type in details of the property they own (it’s a site for hotel owners). At the top of this second page there’s a checkbox that should allow users to select it and automatically fill in other details on the form if necessary.
I’ve got some test code in there to try it out but I get an ‘error on page’ at the bottom of the IE window. The test function I’m using is:
<script type=”text/javascript”>
function changemessage(box)
{
if (box.checked)
{
document.mainform.name.value= ‘test’;
document.mainform.address.value= ‘test2’;
document.mainform.district.value= ‘test3’;
document.mainform.town.value=’test4′;
}
}
</script>
The form itself is defined with:
<form action=”<? echo $PHP_SELF ?>” method=”post” name=”mainform”>
and the checkbox is defined with:
<input name=”setdetails” type=”checkbox” onclick=”changemessage(this)”>
I haven’t a clue about Javascript but getting this right would be a nice extra touch to the wizard.