0

hi all,
In my page i had a dropdown with some values. so when i select others in dropdown i need a textbox to display under that select option. can anyone help me....

Thank u..


i tried this code but this is not working....

<head>
 <SCRIPT LANGUAGE="JavaScript">
 function activate(field) {
  field.disabled=false;
  if(document.styleSheets)field.style.visibility  = 'visible';
  field.focus(); }
function process_choice(selection,textfield) {
  if(last_choice(selection)) {
    activate(textfield); }
  else {
    textfield.disabled = true;    
    if(document.styleSheets)textfield.style.visibility  = 'hidden';
    textfield.value = ''; }}
function check_choice() {
  if(!last_choice(document.demoform.menu)) {
    document.demoform.choicetext.blur();
    alert('Please check your menu selection first');
    document.demoform.menu.focus(); }}
    </script>
 </head>
 <html>
 <body>
 <form name="demoform" action=""><div>
<select name="menu" onchange="process_choice(this,document.demoform.choicetext)">
<option value="0" selected>(please select:)</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="other">other, please specify:</option>
</select>
<noscript>
<input type="text" name="choicetext">
</noscript>
<script type="text/javascript" language="JavaScript">
disa = ' disabled';
if(last_choice(document.demoform.menu)) disa = '';
document.write('<input type="text" name="choicetext"'+disa+
' onfocus="check_choice()">');
if(disa && document.styleSheets)
   document.demoform.choicetext.style.visibility  = 'hidden';
</script>
</div>
<div><input type="submit" value="submit"></div>
</form>

 </body>
 </html>
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sudeepjd
0

Create the textbox as follows <input type="text" name="choicetext"'+disa+' onfocus="check_choice()" style="display:none" id="txt"> And use document.getElementById("txt").style.display="block"; to show and document.getElementById("txt").style.display="none"; to hide.

Put these in your respective JavaScript functions.

Edited by sudeepjd: Formatting change

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.