Dan06 Posted September 23, 2008 Share Posted September 23, 2008 I've put two forms on one page, and I want to display one of them based on the user's previous page selection. My idea was to use an if statement and based on that print a particular div id. I know that in javascript I could use the .getElementById method to print a selected div id. But how would I print a particular div id in php? Below is the code I've put together so far: <?php if($_SESSION['JoinSession'] == "Business"){ echo "div id='businessprofile'"; }?> <div id = "businessprofile"> <form action="<?php echo $editFormAction; ?>" method="post" name="busProForm" id="busProForm"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Company Name:</td> <td><input type="text" name="CompanyName" value="<?php echo htmlentities($row_profileRegister['CompanyName'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Telephone Number:</td> <td><input type="text" name="TelNumber" value="<?php echo htmlentities($row_profileRegister['TelNumber'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Street:</td> <td><input type="text" name="Street" value="<?php echo htmlentities($row_profileRegister['Street'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Street 2:</td> <td><input type="text" name="Street2" value="<?php echo htmlentities($row_profileRegister['Street2'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">City:</td> <td><input type="text" name="City" value="<?php echo htmlentities($row_profileRegister['City'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">State:</td> <td><input type="text" name="State" value="<?php echo htmlentities($row_profileRegister['State'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Zip:</td> <td><input type="text" name="Zip" value="<?php echo htmlentities($row_profileRegister['Zip'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Update record" /></td> </tr> </table> <input type="hidden" name="MM_update" value="busProForm" /> <input type="hidden" name="Id" value="<?php echo $row_profileRegister['Id']; ?>" /> </form> </div> <p> </p> Link to comment https://forums.phpfreaks.com/topic/125492-conditional-form-using-if-statement-and-div-tags/ Share on other sites More sharing options...
aebstract Posted September 23, 2008 Share Posted September 23, 2008 if (value = yes) { echo "<div id=yes>"; } else { echo "<div id=no>"; } just use it in your script however needed Link to comment https://forums.phpfreaks.com/topic/125492-conditional-form-using-if-statement-and-div-tags/#findComment-648773 Share on other sites More sharing options...
Dan06 Posted September 23, 2008 Author Share Posted September 23, 2008 I've used exactly that type of code and unfortunately, it's not working - both forms are still being shown. <?php if($_SESSION['JoinSelection'] == "Individual"){ echo "<div id=individualProfile>"; }?> Any ideas why both forms are still being shown? Link to comment https://forums.phpfreaks.com/topic/125492-conditional-form-using-if-statement-and-div-tags/#findComment-648890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.