Page 1 of 1

long form in a single page with parts that can hide

Posted: Tue Aug 19, 2003 9:52 am
by maroussa
Hello.. I have searched through various forums and I still have not found an answer to my problem, which I will try to describe in as many details I can:

I would like to know if it is possible in PHP (supported by MySQL) to create a form that is displayed in ONE page divided in categories -with many different field types- so that each category can be hidden or shown by clicking the appropriate "show/hide" button/link. The form would be like a "user preferences" page that someone logging in the site can find the submitted information in the future and edit them. If it can be created, is there a tutorial or example of such a form anywhere -about the hide/show attribute-??

Thanx,

Maroussa

Posted: Tue Aug 19, 2003 9:59 am
by greenhorn666
I believe you should do that in JavaScript...
Cause this isn't really a server-side problem you have.
You could still do it in php, having each click on a hide/show button reloading the page AND submit the form, but with one special param that would tell the server not to make the changes persitent in the database, but only to use the submitted values to populate the forms field; and another one telling the server what to hide/show (I would do this param an int, one bit for every part of the form, meaning '0' all hidden, '1' part 1 showed, '2' part 2 showed, '3' part 1 and 2 showed,... I believe you won't have more than 32 parts to your form, so an int should do it).

Still JS would be easier I believe...
having each part being visible or not. But I think such stuff changes from browser to browser (see CSS)

Posted: Sat Aug 23, 2003 4:55 am
by tylerdurden
Something like this should work:

Code: Select all

<html>
<head>
	<title>Javascript hide show</title>
	<meta name="generator" content="BBEdit 7.0">
	<style type="text/css">
<!--
#partone &#123; visibility: hidden&#125;
#parttwo &#123; visibility: hidden&#125;
-->
</style>
<script type="text/javascript" language="Javascript">
<!--
function doIt(which) &#123;
document.getElementById(which).style.visibility = "visible";
&#125;
//-->
</script>
</head>
<body>
<a href="#" onClick="doIt('partone')">show1</a><br><br>
<a href="#" onClick="doIt('parttwo')">show2</a><br><br>

<form>
<table>
	<tr id="partone">
		<td>partone:</td><td><input type="text"></td>
	</tr>
	<tr id="parttwo">
		<td>parttwo:</td><td><input type="text"></td>
	</tr>
</table>
</form>	
</body>
</html>