Hi I have a page that contains several different forms all of which are shown/hidden on the press of the appropriate button.
Now all of them need to include some fields that are retrieved by php from the database but the problem is that my jquery code then fails to hide the fields that are declared later on.
Heres an example of my code:
<form action="controlPanel.php" method="post">
<input class="inputFields" type="text" name="fileName" />
<input class="inputFields" type="text" name="fname" />
<select class="styled-select" id="nameDropdown" name='nameDropdown'>
<option value="0"><span class="formatFreeTxt">Choose a name</span></option>
<?php
foreach ($GLOBALS['myDB']->getList('2') as $i) {
echo "<option value='" . $i['email'] . "'>" . $i['fname'] . " " . $i['lname'] . "</option>";
}
?>
</select>
<input class="inputFields" type="submit" name="textForm" />
</form>
And then I have another form on the div under the above. Like that:
<form action="controlPanel.php" method="post">
<input class="inputFields" type="text" name="textName" />
<input class="inputFields" type="text" name="lname" />
<select class="styled-select" id="nameDropdown" name='nameDropdown'>
<option value="0"><span class="formatFreeTxt">Choose a name</span></option>
<?php
foreach ($GLOBALS['myDB']->getList('2') as $i) {
echo "<option value='" . $i['email'] . "'>" . $i['fname'] . " " . $i['lname'] . "</option>";
}
?>
</select>
<input class="inputFields" type="submit" name="nextTxtForm" />
</form>
My JQuery code is:
function showHideBenef()
{
if($('#nameDropdown').is(':visible'))
{
$('#nameDropdown').fadeOut();
$('#nameTable').fadeIn();
$('#toggleButton').attr('value', 'Choose from existing ones');
$('#chooseTxt').html('New Beneficiary Form');
}
else
{
$('#nameDropdown').fadeIn();
$('#nameTable').fadeOut();
$('#toggleButton').attr('value', 'OR Add a new one');
}
}
Is there any way to make this work without changing the names of each field so that I can actually catch the different posts without the need for checking all the different field names?