ashuraj2163@yahoo.co.in
09-28-2005, 11:23 PM
code given below is not working properly please help me to solve javascript error in selection of listbox of form1. it is giving form1 is not defined error
__________________________________________________________________
<? session_start(); ?>
<? include_once('../include/mysql_connect.php'); ?>
<? ob_start(); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Product</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.dropcontent{
width: 410px;
height: 140px;
border: 1px solid black;
background-color: #FFECC6;
display:block;
}
</style>
<script type="text/javascript">
function check(a)
{
form1.txtCost.value=a;
}
/*
Combo-Box Viewer script- Created by and © Dynamicdrive.com
Visit http://www.dynamicdrive.com/ for this script and more
This notice MUST stay intact for legal use
*/
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.dropcontent{display:none;}\n')
document.write('</style>\n')
}
function contractall(){
if (document.getElementById){
var inc=0
while (document.getElementById("dropmsg"+inc)){
document.getElementById("dropmsg"+inc).style.display="none"
inc++
}
}
}
function expandone(){
if (document.getElementById){
var selectedItem=document.dropmsgform.dropmsgoption.selectedIndex
contractall()
document.getElementById("dropmsg"+selectedItem).style.display="block"
}
}
if (window.addEventListener)
window.addEventListener("load", expandone, false)
else if (window.attachEvent)
window.attachEvent("onload", expandone)
</script>
</head>
<body>
<div align="center"></div>
<p> </p>
<table border="1" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><strong>Special Services </strong></td>
<td><strong>Per Minute Srvice </strong></td>
</tr>
<tr>
<td><table border="1" align="center" cellpadding="1" cellspacing="1">
<?
$query="select * from sservice ";
$result=mysql_query($query)or die(mysql_error."could not retrive information about Special Services");
while($row=mysql_fetch_assoc($result))
{
?>
<tr>
<td><? echo $row['servicetype']; ?></td>
<td><? echo $row['cost'] ?>$</td>
</tr>
<?
}
?>
</table></td>
<td><table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>0.49 cents Per Minute </td>
</tr>
<tr>
<td>Minimum 10 Minute Package </td>
</tr>
</table></td>
</tr>
</table>
<div align="center">
<form name="dropmsgform">
<select name="dropmsgoption" size="1" style="width:300" onChange="expandone()">
<option selected>Special Service</option>
<option>Per Minute Service</option>
<!--<option>What is DHTML?</option> -->
</select>
<br>
<div id="dropmsg0" class="dropcontent">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<form name="form1" method="post">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Select Your Product </td>
<td>
<? $query="select * from sservice ";
$result=mysql_query($query)or die(mysql_error."could not retrive information about Special Service");
?>
<select name="listServiceType" id="listServiceType" onChange='check(listServiceType.options[selectedIndex].value)'>
<?
while($row=mysql_fetch_assoc($result))
{
?>
<option value="<? echo $row['cost'] ?>"> <? echo $row['servicetype'] ?></option>
<?
$x=$row['cost'];
}
?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="left">Your Cost is </td>
<td align="left"><input name="txtCost" type="text" id="txtCost" size="6" maxlength="6" value=<? echo $x ?>>
$</td>
</tr>
<tr>
<td align="right"> </td>
<td> </td>
</tr>
<tr>
<td align="right"><input type="submit" name="Submit" value="Buy"></td>
<td> </td>
</tr>
</form>
</table>
</div>
<div id="dropmsg1" class="dropcontent">
Java is completely different from JavaScript- it's more powerful, more complex, and unfortunately, a lot harder to master. It belongs in the same league as C, C++, and other more complex languages. Java programs need to be compiled before they can run, while JavaScript do not.
</div>
<div id="dropmsg2" class="dropcontent">
DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML. Through them a new level of interactivity is possible for the end user experience.
</div>
</form>
</div>
<p> </p>
</body>
</html>
__________________________________________________________________
<? session_start(); ?>
<? include_once('../include/mysql_connect.php'); ?>
<? ob_start(); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Product</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.dropcontent{
width: 410px;
height: 140px;
border: 1px solid black;
background-color: #FFECC6;
display:block;
}
</style>
<script type="text/javascript">
function check(a)
{
form1.txtCost.value=a;
}
/*
Combo-Box Viewer script- Created by and © Dynamicdrive.com
Visit http://www.dynamicdrive.com/ for this script and more
This notice MUST stay intact for legal use
*/
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.dropcontent{display:none;}\n')
document.write('</style>\n')
}
function contractall(){
if (document.getElementById){
var inc=0
while (document.getElementById("dropmsg"+inc)){
document.getElementById("dropmsg"+inc).style.display="none"
inc++
}
}
}
function expandone(){
if (document.getElementById){
var selectedItem=document.dropmsgform.dropmsgoption.selectedIndex
contractall()
document.getElementById("dropmsg"+selectedItem).style.display="block"
}
}
if (window.addEventListener)
window.addEventListener("load", expandone, false)
else if (window.attachEvent)
window.attachEvent("onload", expandone)
</script>
</head>
<body>
<div align="center"></div>
<p> </p>
<table border="1" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><strong>Special Services </strong></td>
<td><strong>Per Minute Srvice </strong></td>
</tr>
<tr>
<td><table border="1" align="center" cellpadding="1" cellspacing="1">
<?
$query="select * from sservice ";
$result=mysql_query($query)or die(mysql_error."could not retrive information about Special Services");
while($row=mysql_fetch_assoc($result))
{
?>
<tr>
<td><? echo $row['servicetype']; ?></td>
<td><? echo $row['cost'] ?>$</td>
</tr>
<?
}
?>
</table></td>
<td><table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>0.49 cents Per Minute </td>
</tr>
<tr>
<td>Minimum 10 Minute Package </td>
</tr>
</table></td>
</tr>
</table>
<div align="center">
<form name="dropmsgform">
<select name="dropmsgoption" size="1" style="width:300" onChange="expandone()">
<option selected>Special Service</option>
<option>Per Minute Service</option>
<!--<option>What is DHTML?</option> -->
</select>
<br>
<div id="dropmsg0" class="dropcontent">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<form name="form1" method="post">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Select Your Product </td>
<td>
<? $query="select * from sservice ";
$result=mysql_query($query)or die(mysql_error."could not retrive information about Special Service");
?>
<select name="listServiceType" id="listServiceType" onChange='check(listServiceType.options[selectedIndex].value)'>
<?
while($row=mysql_fetch_assoc($result))
{
?>
<option value="<? echo $row['cost'] ?>"> <? echo $row['servicetype'] ?></option>
<?
$x=$row['cost'];
}
?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="left">Your Cost is </td>
<td align="left"><input name="txtCost" type="text" id="txtCost" size="6" maxlength="6" value=<? echo $x ?>>
$</td>
</tr>
<tr>
<td align="right"> </td>
<td> </td>
</tr>
<tr>
<td align="right"><input type="submit" name="Submit" value="Buy"></td>
<td> </td>
</tr>
</form>
</table>
</div>
<div id="dropmsg1" class="dropcontent">
Java is completely different from JavaScript- it's more powerful, more complex, and unfortunately, a lot harder to master. It belongs in the same league as C, C++, and other more complex languages. Java programs need to be compiled before they can run, while JavaScript do not.
</div>
<div id="dropmsg2" class="dropcontent">
DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML. Through them a new level of interactivity is possible for the end user experience.
</div>
</form>
</div>
<p> </p>
</body>
</html>