Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to print a alert massage wit

Status
Not open for further replies.

peppe71

Technical User
Feb 6, 2002
27
0
0
IT
I want to print a alert massage with the value of select in this mode:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<SCRIPT LANGUAGE&quot;Javascript&quot;>
<!--
function getname(str)
{
alert(&quot;Ciao, &quot;+str+&quot;!&quot;);
}
//-->
</SCRIPT>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;>
<select name=&quot;select&quot; onblur=&quot;getname(this.value)&quot;>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<p><input type=&quot;text&quot; name=&quot;textfield&quot; >
</p></form>
</body>
</html>

Why this.value don't display me nothing?
 
Please do an effort to use correct English and spelling.

<select name=select onblur=&quot;getname(this.options[this.selectedIndex].value)&quot;>

this.value would work with some JavaScript engines but using the selectedIndex and fishing the information out of the options is an older method accepted by more browsers (old and new alike).

Hope this helps. Gary Haran
 
Your error is that all options doesn not have any default value, like this:
<option value=&quot;1&quot;>1</option>

Also, I'd recommend to change this:
<select name=&quot;select&quot; onblur=&quot;getname(this.options[this.selectedIndex].value)&quot;>

so it will work as it should also in NN4.x


If you don't want to add values to every <option> you can use this:

<select name=&quot;select&quot; onblur=&quot;getname(this.options[this.selectedIndex].text)&quot;>

It will do the same thing.


Also, don't call <select> as &quot;select&quot;, never give names that are reserved words.

good luck
 
Thank you and excuse me for my english
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top