var vvalue=document.forms[0].fname.selectedIndex;
var vovalue=document.forms[0].fname.options[vvalue].value

<select name="fname">
<option value="Arial">Arial</option>
<option value="Symbol">Symbol</option>
<option value="Rockwell">Rockwell</option>

Without seeing the rest of the code and markup it's a bit of a guess, but I would start out by modernising your script to DOM compatible standard. Try:

<script type="text/javascript">
var vovalue = document.getElementById("fname").options[(document.getElementById("fname").selectedIndex)].value;
</script>

<select name="fname" id="fname">
<option value="Arial">Arial</option>
<option value="Symbol">Symbol</option>
<option value="Rockwell">Rockwell</option>
</select>

thanks a lot for your response.I have changed the code as

<select name="fon" id="fname">
<option value="Arial">Arial</option>
<option value="Symbol">Symbol</option>
<option value="Rockwell">Rockwell</option>

var vofvalue = document.getElementById("fname").options[(document.getElementById("fname").selectedIndex)].value;


<font face="'+vofvalue+'" size='+vofsize+'>


Still not working

Would need to see the full code in the context of the page to determine what is meant to be happening and why it is not working. Do you have a link to a page we can view?

Would need to see the full code in the context of the page to determine what is meant to be happening and why it is not working. Do you have a link to a page we can view?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
function displayHTML()
{
var tablestring='';
var lnstr=document.forms[0].t2.length;
var vrows=1.5;
var vroundrows=1.25;
var vprintstr='';
var inf = document.forms[0].t1.value;
var vt2 = document.forms[0].t2.value;
var vlabels = document.forms[0].tn.value;
alert("opening!!!!!!");
var vofvalue = document.getElementById("fname").options[(document.getElementById("fname").selectedIndex)].value;
alert("opening2!!!!!!!!");
var vofsize=document.getElementById("fsize").options[(document.getElementById("fsize").selectedIndex)].value;
var vlbl=document.forms[0].lsize.selectedIndex;
var textsize=document.forms[0].lsize.options[vlbl].value;

if(inf.length>30)
{
alert ("line 1 should not exceed 30 characters")
t1.value="";
t1.focus();
return;
}
if(vt2.length>30)
{
alert ("line 2 should not exceed 30 characters")
t2.value="";
t2.focus();
return;
}
vprintstr='<a href="javascript:window.print()">Print</a> - <a href="javascript:window.close()">Close Window</a><br><br>'
document.write(vprintstr);
alert("working");
tablestr='<table border="1" cellspacing=10><font face="'+vofvalue+'" size='+vofsize+'>';
for (var x = 1; x <= vlabels; x++)
{
//tablestr=tablestr+'<tr>'+ inf +'</tr><tr>'+ vt2+'</tr>'
tablestr=tablestr+'<table width="310" height="10" align="centre"><font face="'+vofvalue+'" size='+vofsize+'><tr>'+ inf +'</tr></font></table><table width="310" height="60" ><font face="'+vofvalue+'" size='+vofsize+'><tr>'+ vt2+'</tr></font></table></tr>';
}
alert("wo1");
tablest=tablestr +'</font></table>';
alert("wo2");
document.write(tablest);
alert("wo3");
}
</script>
</head>
<body bgcolor="#cfcc3b" LEFTMARGIN=40 TOPMARGIN=5>
<br><br>
<table bgcolor="#201d5b" cellspacing=5 width="900" height="10" >
<tr><td width=20 height="10"></td><td align=center><font color="#ffffff" size=7></font></td></tr>
</table>
<table bgcolor="#201d5b" cellspacing=5 width="900" height="360" ><form>
<tr>
<td width=50></td>
<td width=300 height="10"><font color="#ffffff" size=4>Enter line 1</td>
<td><input type="text" name="t1" value="" size=25></td>
</tr>
<tr>
<td width=50></td>
<td width=300 height="10"><font color="#ffffff" size=4>Enter line2</td>
<td><input type="text" name="t2" value="" size=25></td>
</tr>
<tr>
<td width=50></td>
<td width=300 height="10"><font color="#ffffff" size=4>Number of Labels</td>
<td><input type="text" name="tn" value="" size=25></td>
</tr>
<tr>
<td width=50></td>
<td width=300 height="10"><font color="#ffffff" size=4>Select Label Size</td>
<td><select name="lsize" ><option value="1" width=20 >3.5 X 2.5
<option value="2">2.5 X 1.5</option></td>
</tr>
<tr>
<td width=50></td><td width=300 height="10"><font color="#ffffff" size=4>Select Font Style</td>
<td><select name="fon" id="fname">
<option value="Arial">Arial</option>
<option value="Symbol">Symbol</option>
<option value="Rockwell">Rockwell</option></td>
</tr>
<tr>
<td width=50></td><td width=300 height="10"><font color="#ffffff" size=4>Select Font Size</td><td>
<select name="siz" id="fsize" >
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option></td></tr>
</form>
</table>
<br>
<a href="javascript:void(0);" onclick="displayHTML();"><input type="button" value="PrintPreview" onclick="displayhtml():"></a><br>
</body>
</html>

Plz let me know the response

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.