Forum Moderators: open
.style.visibility='hidden'hides the element from view, but the space that was occupied by the element is still... occupied (by what looks like empty space). Setting
.style.display='none'hides the element from view AND allows elements that follow it to occupy the space that it once occupied.
if (isset($_POST['whatever']) and ! empty($_POST['whatever'])) {
switch ($_POST['whatever']) {
case 1:
include('form1.txt');
break;
case 2:
include('form2.txt');
break;
}
else {
if (isset($_POST['your-question'])) {
process_the_data_and_respond();
}
else { include('select-list-form.txt'); }
}
This is line 28: document.getElementById('form').style.visibility ='hidden';
Message: Object required
Line: 28
document.getElementById('form') searches the document for an element with id="form". There isn't one, so it doesn't return an object as expected. You then try and access the style property of this non-object, hence the error.
The only thought, however, is can the user switch between forms before submitting and switch back as they please?
I'd love to try ajax but unfortunately I've never played with it, and wouldn't even know where to begin or how to implement it.