Jump to content

Recommended Posts

Hello everyone,

 

I am new to PHP to so please bear with me. I need suggestion to achieve a task.

I have to make a form where in initially there will be a combox box. Depending onthe selection ie value1, value2, value3 etc.......a sub form should open below the combo box.

 

This forms r different for different value...and at the end there will be a submit button to submit the form.

 

Can anyone tell me the how many ways this is possible and which is the efficient one.???

 

Thanks a lot in advance....

Link to comment
https://forums.phpfreaks.com/topic/222568-combo-box-on-click-suggestion/
Share on other sites

Here's a quick example:

 

<html>

<body>

<script type="text/javascript">

function showForm(formName)
{
if(formName.length > 0)
{
	document.forms["form1"].style.display = "none";
	document.forms["form2"].style.display = "none";
	document.forms["form3"].style.display = "none";

	document.forms[formName].style.display = "";
}
}

</script>

<select onchange="showForm(this.value)">
	<option value="">Select a form...</option>
	<option value="form1">Form 1</option>
	<option value="form2">Form 2</option>
	<option value="form3">Form 3</option>
</select>

<form name="form1" style="display:none;">
	form1: <input type="hidden" name="selected_form" value="form1">

	<input type="text" name="test1" /><br />
	<input type="submit" value="Submit 1" />
</form>

<form name="form2" style="display:none;">
	form2: <input type="hidden" name="selected_form" value="form2">

	<input type="text" name="test2" /><br />
	<input type="submit" value="Submit 2" />

</form>

<form name="form3" style="display:none;">
	form3: <input type="hidden" name="selected_form" value="form3">

	<input type="text" name="test3" /><br />
	<input type="submit" value="Submit 3" />

</form>

</body>


</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.