in javascript, I want to find a way like below.

If value = 1 then
placeholder = dropdown
placeholder = textbox
end if

Is it possible in Javasript or jquery?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
The answer is simple: Yes, it is possible.

But it depends on what you wanna do.
If the "value" is coming from a user input checkbox then you have to disable and hide the one control and enable and show the other control.
On Submit the disabled form controls are not submitted.

So what is your scenario for this requirement?
ITsolutionWizardAuthor Commented:
the value came from the <select></select>

The <placeholder> should be generic. It is not necessary to do disabled or not disabled.
just like what i mentioned. value 1 show drop down value 2 show text box.

Is that clear ?

ZvonkoSystems architectCommented:
That is clear but my question is: are you sure that you want to loose the text input or the dropdown selection when the user switches the selector value?

Therefor the most developer decide to have both controls on the form and enable the requested one as selected.

The "dynamic" approach has NO advantages, only difficulties. For example: where do you get the dropdown options when you have 50 states for selection?
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

ZvonkoSystems architectCommented:
This is an example that works but that I would not recommend:
<title>Zvonko &#42;</title>
function switchOption(theSel){
  $("inputArea").innerHTML = $("inputTemplate"+theSel.value).innerHTML;

function $(theId){
  return document.getElementById(theId);
<select name="userSel" onChange="switchOption(this)">
<option value="1">Text</option>
<option value="2">DropdownText</option>
<span id="inputArea">
<input type="text" name="usrInput" >
<input type="submit">
<form name="hiddenForm" style="display:none;">
<span id="inputTemplate1">
<input type="text" name="userInput" >
<span id="inputTemplate2">
<select name="userInput">
<option value="1">One</option>
<option value="2">Two</option>
<option value="2">Three</option>

Open in new window

I would prefer disabling and enabling hidden elements on same form area.
ITsolutionWizardAuthor Commented:
no. this is not what I am asking for. I am asking for a <place holder></place holder> in html so it is just like container. It can accept text box, drop down, and etc. based on the value it is provided.

Your code have static html text and select.
ZvonkoSystems architectCommented:
the placeholder needs the final code for the input or for the select.
where should that select field definition come from?
???? ITsolutionWizard, I have read through this, and I am unable to see or get what you may mean by your using the -
"  a <place holder></place holder> in html  so it is just like container."

I do not believe that this will be an effective way (if you can do that), ?
What I would do is have an existing HTML element like <span> or <div>, , AS A CONTAINER that you dynamically load the "contents" into as a <select> or <textbox>,  if you have an empty
     <span id="dynamic"></span>
it will disappear, and in JS you can load something into the HTML for it -

document.getElementById("dynamic").innerHTML = '<select name="d">
<option value="a">1</option>
<option value="b">2</option>
and it will show the <select> or anything you place in it correctly as DHTML

Although you possibly  can put some <place holder> in it to the HTML document, you would then have to find it and remove it, then you can get use the DOM to "create" a <select> and add options, then you would need to use an insert command to place that element,  hopefully, in the same place of the Document structure, where you removed the place holder, not so easy.
ZvonkoSystems architectCommented:
@Zvonko, more than likely, but I hoped to separate a Place Holder from the change of HTML that most JS uses, did not think that ITsolutionWizard got that, ,  or was used to templates or other programming that uses place holders.
ITsolutionWizardAuthor Commented:
Guys, I know it may be not very easy. In the same case, I can do that in . Since my project is in html5 , that why I asked this question.

If you don't have solution or too hard for you. It is ok. But I have to keep the question as it.

@ ITsolutionWizard, You say that your question is the same, in your last comment. Because of my misunderstanding or "not familiar with" your term and use of what you call a -
also not sure also about why you say that HTML5 is used and makes a difference for us to make a solution?
So sorry about my lack of understanding in this.

It may help us if you can describe the "steps" or methods, you need to have in your javascript function so that when a <select> is changed from 1 to another then a dropdown or textbox is placed in your web page.

You say this - "I am asking for a <place holder></place holder> in html so it is just like container."
I have not seen this <place holder> Tag used in a web page HTML, so I do not see what you may need.
So It would help us very much, if you can show us the exact "HTML" that you start with, where you have this <place holder> Tag used that will be changed to <select> (dropdown) if the chose select is changed to one.

Also, can you say if the "Dynamic" (not static) content of the inserted <select> and textbox is from your ASP server code?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZvonkoSystems architectCommented:
@ ITsolutionWizard: you are right, its too hard for me <|;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.