473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to get a dynamic text box for input

Hi,

I have a combo box with few predefined values, but i want to allow the user even to add a new value which is not available in the list, what can i do for this?,

i am using PHP and MySQL

for example:

<select name="Category">
<option value="SoftWare"> Soft Ware</option>
<option value="HardWare"> Hard Ware</option>
<option value="Docs"> Documents</option>
<option value="Others"> Others </option>
</select>

I would like to allow the user to enter some value in a text box which should be displayed automatically when i select the option of "Others" in the Combobox.

Thank you.
Feb 4 '08 #1
3 5985
venkatdrp,

Welcome to TSDN!

Well since PHP is server-side this can't be dynamic in the sense of a postback refresh without using client-side scripting like js. I would imagine you could have a seperate submit that sends the value back to the current script and conditionally appends the <option> with the passed information.

Or you could store the option values in a table and use the submit coupled with an insert into and re-code the option selects to be dynamic as part of a while/for loop.

Regards,
Jenkins
Feb 4 '08 #2
Hi,

I have a combo box with few predefined values, but i want to allow the user even to add a new value which is not available in the list, what can i do for this?,

i am using PHP and MySQL

for example:

<select name="Category">
<option value="SoftWare"> Soft Ware</option>
<option value="HardWare"> Hard Ware</option>
<option value="Docs"> Documents</option>
<option value="Others"> Others </option>
</select>

I would like to allow the user to enter some value in a text box which should be displayed automatically when i select the option of "Others" in the Combobox.

Thank you.
Hi, you need to use javascript for that task:

for example:

<script language="JavaScript">

function handleText(elem)
{
document.myform.MyTextBox.value = elem.value;
}
</script>

//then create your combobox with a event(onChange) handler
<select name="Category" onChange="handleText()">
<option value="SoftWare"> Soft Ware</option>
<option value="HardWare"> Hard Ware</option>
<option value="Docs"> Documents</option>
<option value="Others"> Others </option>
</select>
Feb 5 '08 #3
ifedi
60
I guess what you're trying do is NOT really appending an extra option to the select/option group, but revealing the textbox when 'others' is selected, so the user can enter the value.

In that case the answer is JavaScript. You may need to make a conditional script, to show the new textbox element only when 'others' is selected. You can then you php to recollect the POST or GET data and do whatever you want with it.

Best of luck.
Regards, Ifedi.
Feb 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and...
4
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see...
3
by: JDPope | last post by:
I have a situation which I cannot get a good lead on how to resolve. One of the applications I support uses the Hibernate software to generate SQL. The app is JAVA with JDBC. In testing the users...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
1
by: gau.tai | last post by:
I have a form in which I am generating dynamic fields. I can do this fine, but when I go to validate them there are errors. The non- dynamic fields validate correctly. Below is the html and js. ...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
3
by: azegurb | last post by:
hi I have just took from internet dinamic table. this table is dynamic and its rows dynamically can be increased. but i would like how create SUM function that automatically sums each added row...
2
by: yomadhu | last post by:
I created a dynamic form in javascript. Am unable to get those values in to php to display. I need all details. If i add 10 rows the i need to display those all values. Can any one help me for that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...

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.