...

View Full Version : how to create The Function



Umesh123
12-29-2010, 02:11 PM
hello friends..
I am working on the html code in which i using the List Control
The Requirement that among the List element in which I choose the locations
there is option in which whenever i select the option None From The List then it should Disply the empty textbox
So how the function is declared
Please tell me...:)

devnull69
12-29-2010, 03:22 PM
Like this?

http://jsbin.com/ituho3

Umesh123
12-30-2010, 11:20 AM
Like this?

http://jsbin.com/ituho3

Hello Friend...
It is absolutely right.
But whenever I am trying to create that code its not working My Code is
not working....
I have type the same code which you have given....:)

Umesh123
12-31-2010, 01:01 PM
Like this?

http://jsbin.com/ituho3

hello Friends...
this is my code from the recent blog post.
I want the following functionality...
among the select option group control which consists of the name of the cities whenever I select the element from the lists then doesn't occur any event.
but the list contains the element none from the list
whenever I select the element none from the list then it displays the empty textbox but the following code is not working...please tell me


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function showtextbox()
{
if(this.value==5)
{document.getElementById('textbox').style.display='block';}
else{document.getElementById('textbox').style.display='home';}
}

var loc=document.getElementByName('locations') [0];
if(loc.addEventListener){loc.addEventListener('change',showtextbox,false);}
else if(loc.attachEvent){loc.attachEvent('onchange',showtextbox);}
</script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
</head>
<body>
<select name="locations" size="5">
<option value="1">Mumbai</option>
<option value="2">Pune</option>
<option value="3">Nashik</option>
<option value="4">Aurangabad</option>
<option value="5">None</option>
</select>
<input id="textbox" type="text"/ style="display: none;">
</body>
</html>

Old Pedant
01-01-2011, 12:18 AM
You have a couple of errors there. But why don't we just make it simpler?


<html>
<head>
<title>Demo</title>
</head>
<body>
<form><!-- NEVER use form fields such as select and input without a form -->
Location:
<select name="locations"
onchange="document.getElementById('other').style.display=this.value=='5'?'block':'none';">
<option value="1">Mumbai</option>
<option value="2">Pune</option>
<option value="3">Nashik</option>
<option value="4">Aurangabad</option>
<option value="5">Other</option>
</select>
<div id="other" style="display: none;">
Other: <input name="otherlocation" type="text">
</div>
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum