469,946 Members | 1,929 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

show/hide text field from select(dropdown)

What I am trying to do is add first text field right after a dropdown menu only if the user selects a first option, when a user selects second option then second text field is opened

I am new to java script so pls help me.....
Apr 7 '11 #1
4 2564
9,735 Expert Mod 8TB
Could you please provide us more details about what you have tried so far to solve this problem.

Do you have any JavaScript implemented at all to solve this problem?

Are you having problems generating the JavaScript?

If you have tried implementing a JavaScript solution for this application, and you are experiencing problems...what are the error messages that you are getting?

Considering using JavaScript debugging tools that come built into IE8/9, Safari, or Chrome. If you are using FireFox, then consider downloading Firebug: an application that allows you to debug CSS and JavaScript problems.

Apr 7 '11 #2
basic javascript methods of access html tags is :

had to give id to each element u wanna access (read or write) then use document.getElementById('id')

this will return the object u wanna access..

to insert value to <div> use innerHTML='value'

to get value from text fileld use .value

to inser value to text field use .value='value'

hope this helps.
Apr 8 '11 #3
hi, i am new to java script and php also. so if you kindly give me the details, it will help me.

Apr 8 '11 #4
9,735 Expert Mod 8TB
PHP runs on a web server and is used to dynamically generate HTML that is sent to the web browser to display to the end user.

JavaScript runs within the web browser and allows you to modify things client-side while the user is using the web page.

Without JavaScript you would have to send a request to the server (to the PHP code) so that it could generate HTML based on the user's actions. JavaScript is faster and uses less bandwidth than posting back to the server....however JavaScript can't do everything (for example it can't connect to a database)

As Shenno was saying, JavaScript has a document.getElementById() method that allows you to access an HTML element on the page. This method accepts a parameter: the ID of the HTML element that you want to work with.

So this means that your PHP script has to generate unique IDs for each HTML element that it generates...well, at least for the HTML elements that you need access to in your JavaScript code.

Please note that ID's for HTML elements must be unique on the page. Be aware of this when you are looping or you are calling other PHP scripts to help generate the code.

To get started, you may want to check out the Offsite JavaScript Links thread that is sticky in the JavaScript forum.
Apr 12 '11 #5

Post your reply

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

Similar topics

20 posts views Thread by Dannyboyo | last post: by
2 posts views Thread by Wolfgang | last post: by
1 post views Thread by nubianqnn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.