473,569 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Form Items

Hello there I am trying to create A form that its fields will depend on a
form menu.
for example.
/*************** *************** *************** **/
<form name="form1" method="post" action="">
<select name="select">
<option value="1">optio n 1</option>
<option value="2">optio n 2</option>
<option value="3">optio n 3</option>
</select>

Text field 1<input type="text" name="textfield ">
Text Field 2<input type="text" name="textfield 2">
Text Field 3 <input type="text" name="textfield 3">
Text Field 4 <input type="text" name="textfield 4">

<input type="submit" name="Submit" value="Submit">
</form>
/*************** *************** *************** **/
When the option 1 is selected only the textfields 1 and 2 to appear,
when option 2 is selected only textfields 1 and 3 to appear and so on... any
combination I would like.

I tried puting the textfields in "if" statments but i don't like it. its too
messy PHP and HTML code.
Any Ideas of how this could be done better ? If someone did something
similar before and has a relative link it would be good as well.

Thanks
Angelos!!
Jul 17 '05 #1
3 1427
While the city slept, Angelos (an*****@redcat media.net) feverishly typed...
Hello there
Hi
I am trying to create A form that its fields will depend
on a form menu.
for example. [...] When the option 1 is selected only the textfields 1 and 2 to appear,
when option 2 is selected only textfields 1 and 3 to appear and so
on... any combination I would like.


I'm afraid I can't imagine how you are going to achieve this using PHP, as
PHP does its work on the server, then delivers the page source to the user.
You would be better looking for a client-side solution (eg. javascript) for
this, such as the following list of options on Google:
http://tinyurl.com/9oopm

Just remember that not all users will have javascript turned on (or even
available to them), so make sure that your form will still work without it.

Hope that helps.

Cheers,
Nige

--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. ni***@DOG.nigen et.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!"
Jul 17 '05 #2

"nice.guy.n ige" <ni********@dea dspam.com> wrote in message
news:42******** *************@n ews.dial.pipex. com...
While the city slept, Angelos (an*****@redcat media.net) feverishly
typed...
Hello there


Hi
I am trying to create A form that its fields will depend
on a form menu.
for example.

[...]
When the option 1 is selected only the textfields 1 and 2 to appear,
when option 2 is selected only textfields 1 and 3 to appear and so
on... any combination I would like.


I'm afraid I can't imagine how you are going to achieve this using PHP, as
PHP does its work on the server, then delivers the page source to the
user.
You would be better looking for a client-side solution (eg. javascript)
for
this, such as the following list of options on Google:
http://tinyurl.com/9oopm

Just remember that not all users will have javascript turned on (or even
available to them), so make sure that your form will still work without
it.

Hope that helps.

Cheers,
Nige


Thanks Nige I think you are right ... if I don't use javascript I am going
to create seperate forms for each option...
Jul 17 '05 #3
Angelos wrote:
Hello there I am trying to create A form that its fields will depend on a
form menu.
for example.
/*************** *************** *************** **/
<form name="form1" method="post" action="">
<select name="select">
<option value="1">optio n 1</option>
<option value="2">optio n 2</option>
<option value="3">optio n 3</option>
</select>

Text field 1<input type="text" name="textfield ">
Text Field 2<input type="text" name="textfield 2">
Text Field 3 <input type="text" name="textfield 3">
Text Field 4 <input type="text" name="textfield 4">

<input type="submit" name="Submit" value="Submit">
</form>
/*************** *************** *************** **/
When the option 1 is selected only the textfields 1 and 2 to appear,
when option 2 is selected only textfields 1 and 3 to appear and so on...
any combination I would like.

I tried puting the textfields in "if" statments but i don't like it. its
too messy PHP and HTML code.
Any Ideas of how this could be done better ? If someone did something
similar before and has a relative link it would be good as well.

Thanks
Angelos!!


A good way to avoid client-side processing is to do the old "wizard"
approach. It has the advantage the users expect it and understand it.

On page 1 they make a selection from the <select...> element. Off we go to
the server, where you look at the option, save it in the session, and
decide which fields to show on page 2. Or even easier, which page to go
to.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec )ure(Dat)a(.com )
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13209
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax: Hunter_69. Here is what the form looks like. I have the difficulty of inserting the multiple items selected by the user the first time he visits and uses...
3
5742
by: Jack Black | last post by:
Using VS.Net 2k3 to build ASP.Net app with VB code-behind pages... Hi, all! I've been struggling with getting a dynamically-generated CheckBoxList generated. I've finally been able to get the list generated, but now there are two problems I haven't been able to overcome: 1) ASP.Net is munging the checkbox ID/Names of the checkboxes: I...
1
2876
by: JMann101 | last post by:
I am writing a ASP.NET(VB) application and am having some trouble. I have a datagrid which list users and when an admin clicks "edit" a defined column becomes visible and a dynamic listbox control is added to that column/row. When the admin clicks "update" I am unable to retrieve the values that were selected from that listbox. Basically,...
1
2561
by: segue | last post by:
I'm dynamically creating/populating a checkbox list and adding it to a web form. I want to when checking an item in the list have the autopostback retrieve the selected item. I'm dynamically adding that control as: Protected WithEvents userSelectionList, Ulist2 As System.Web.UI.WebControls.CheckBoxList Protected WithEvents...
0
2006
by: =?Utf-8?B?QmlzaG95?= | last post by:
Hi All, I have a Right to Left web page with asp.net 2.0 containing a horizontal menu. The menu is right to left as the page. The problem is the submenu items or the dynamic menu items are not aligned right, so the menu has a bad shape. -------------------------------------------------------------
1
4645
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be...
0
3486
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row...
2
5012
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation is this, I have a page which uses multiple postbacks to generate a list of dynamic text boxes with appropriate labels. However, when I do the final...
4
1838
by: libish | last post by:
hi all... can any one help me by suggesting a way to get items in dynamic form? here what i'm doing is , i'm displaying a dynamic form. in that form i have a main menu and this main menu contains a menu item "OK". here the dynamic form consist of some labels, list items and all. when i click on the "OK" menu item, an event occurs and i've...
13
10702
by: tommymo | last post by:
Hi everyone I'm new to this site and the world of ASP.Net C# programming. I have been learning controls and integrating them with a SQL database. So far I have been able to move along and understand static controls. However I would like to move on to attempt to create some dynamic controls. So I set out to work with a radiobuttonlist...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.