473,387 Members | 1,771 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,387 software developers and data experts.

beginner:dynamic form field

hello,

i have a form with a listbox;
in this listbox people can choose between 'yes' and 'no';

if the choose 'yes' i want a new text field to appear.

if the choose 'no' nothing happens;

but how do i do this?

i have looked on the internt but all i found where very complicated examples
that i did not unserstand at all.

i am looking for a very straight forward example, or solution.

thanks,
May 18 '06 #1
3 1486
nescio wrote:
hello,
Hi,

i have a form with a listbox;
What is a listbox?
Do you mean a SELECT?
in this listbox people can choose between 'yes' and 'no';

if the choose 'yes' i want a new text field to appear.

if the choose 'no' nothing happens;

but how do i do this?

i have looked on the internt but all i found where very complicated
examples that i did not unserstand at all.

i am looking for a very straight forward example, or solution.

thanks,


Sounds like homework to me, so I'll just give you a few hints.

1) how to find which option is selected?
look up: selectedIndex
Learn how to adres a SELECT in a form.
This will end up like: document.forms.myForm.mySelect.selectedIndex
2) How to hide a part of the page?
Look up: DIV or SPAN and pay attention to a property named 'display' which
should be 'none' to hide something and 'block' (for DIV) or 'inline' (for
SPAN).

Hope that helps.

Regards,
Erwin Moller
May 18 '06 #2
nescio said the following on 5/18/2006 7:51 AM:
hello,

i have a form with a listbox;
in this listbox people can choose between 'yes' and 'no';

if the choose 'yes' i want a new text field to appear.

if the choose 'no' nothing happens;

but how do i do this?
One of several ways. You can make that text field always be there and
make it visible/hidden based on the value of the select element.
i have looked on the internt but all i found where very complicated examples
that i did not unserstand at all.


Complicated examples of hiding/showing an element? I don't believe that.

<select onchange="hideElement('divToHide',this.value)">
<option value="visible">Yes
<option value="hidden">No
</select>
<div id="divToHide" style="visibility:visible">
<input name="myInput">
</div>

<script type="text/javascript">
function hideElement(elem,visibilityMode){
document.getElementById(elem).style.visibility = visibilityMode;
}
</script>

That is it at it's simplest. You could also use createElement and
appendChild to create the element but that can get messy in a hurry
trying to remove it.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 18 '06 #3

thanks for your help, i now have something to work on
May 18 '06 #4

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

Similar topics

4
by: Terry | last post by:
I need some help refining an MS 2000 relational databse. I have created a simple relational database using two tables, 'Student Details', 'Exam Details' and two forms, 'Input/Edit Exam Details',...
3
by: Chung Hang Shum | last post by:
I'm a beginner in ASP.Net. I'd wroten mange asp code before and now I need to transfer them from asp to asp.Net. In classical ASP you can write code like this: <% If strRequest = "ConfirmPasswd"...
6
by: MROPARTNER | last post by:
I have a field in a form called "Date" I am looking to fill this text field with the current date. Is there a way to do this with ASP or an easier way? Thanks Bill
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
4
by: Jessica | last post by:
Can someone look at this code and tell me what is wrong? The error message says "Line 8 Char 1 'dealerId' is undefined" But I thought that I stated everything correctly. Do I have any syntax errors...
1
by: RoyNg | last post by:
Dear all guys, I am beginner for Access VBA. I am programming Access 2003. I have one form containing one subform. The form mainly perform customer payment function. When user chooses...
5
by: nescio | last post by:
hello, i am making a form using php/html/javascript a part of the form is (email address) comming from a database. the amount of addresses is always different. every address has a checkbox....
6
by: robtyketto | last post by:
Greetings, Im a newbie to JSP/Javascript (unfortunalley). However I found enough example to create code that connects to my access db and populates two combo boxes. The selection of the...
1
by: rubenhan | last post by:
Hi guys, I'm a javascript beginner and I am trying to write this simple javascript code that will add text field when I type some texts in the preexisting text field. When the text field is...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.