PDA

View Full Version : Little problem with menu



Nate_Bro
09-07-2004, 08:34 PM
Ok, here is the link http://www.churchforchildren.com/Chat/XP_Test/xp_test.htm my problem is i want it to close the sub menus on a mouse click anywhere on the page, not just on the buttons. any suggestions? :)

I've only been doing javascript for about two months, and i don't know how the get a lot of stuff, like when you click the mouse anywhere on the page or right click, and if you know, i'm also tying to add a percent to an equation, like so, the problem is in the tax() function. thanks.




<Head>

<FORM NAME="number">

<table cellpadding="0" cellspacing="0" width="100%" height="180">
<tr>
<td valign="top">
<p align="right">Quantity</td>
<td valign="top">
<p align="right">

<INPUT TYPE="text" Value=" " NAME="num1" Value="0" size="5" onfocusout="grand()" ></td>
<td valign="top">
<p align="right">Books Price $&nbsp;&nbsp;&nbsp; </td>
<td valign="top">

<INPUT TYPE="text" Value="35.00" NAME="num2" size="8"></td>
<td valign="top">
<p align="right">

&nbsp;</td>
<td height="35"></td>
</tr>
<tr>
<td valign="top">
<p align="right">Quantity</td>
<td valign="top">
<p align="right">

<INPUT TYPE="text" Value=" " NAME="num1a" Value="0" size="5" onfocusout="grand()" ></td>
<td valign="top">
<p align="right">Shirts Price $&nbsp;&nbsp;&nbsp;
</td>
<td valign="top">


<INPUT TYPE="text" Value="12.00" NAME="num2a" size="8"></td>
<td valign="top">
<p align="right">


&nbsp;</td>
<td height="42">&nbsp;</td>
</tr>
<tr>
<td width="124" valign="top">
<p align="right">Quantity </td>
<td width="50" valign="top">
<p align="right">

<INPUT TYPE="text" Value=" " NAME="num1b" Value="0" size="5" onfocusout="grand()" ></td>
<td width="325" valign="top">
<p align="right">Junk&nbsp; Price&nbsp;&nbsp;$&nbsp;&nbsp;&nbsp; </td>
<td width="65" valign="top">


<INPUT TYPE="text" Value="18.00" NAME="num2b" size="8"></td>
<td valign="top">
<p align="right">


&nbsp;</td>
<td height="77">&nbsp;</td>
</tr>
<tr>
<td colspan="4" valign="top" align="center">
<p align="right">Grand Total $&nbsp;&nbsp;
<input type="text" name="numb4" size="8" value="0.00">&nbsp;&nbsp; </td>
<td width="150" valign="top" align="center">
<p align="right">

<INPUT TYPE="button" NAME="numb45" value="Total" size="8" onclick="grand()" >&nbsp;&nbsp;
<INPUT TYPE="reset" NAME="none56" Value="Reset">&nbsp;&nbsp; </td>
<td height="18" width="18%"> </td>
</tr>
<tr>
<td colspan="4" valign="top" align="center">
&nbsp;<p align="right">Enter state tax rate below&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p align="right">&nbsp;&nbsp;&nbsp;

<INPUT TYPE="text" Value=" " NAME="taxper" size="4" >&nbsp;
%&nbsp;&nbsp;&nbsp;

<INPUT TYPE="button" NAME="tax" value="Add Tax" size="8" onclick="tax()" >&nbsp;&nbsp;
</p>
<p align="right">

<INPUT TYPE="text" Value=" " NAME="taxdone" size="20" ></td>
<td width="150" valign="top" align="center">
&nbsp;</td>
<td height="9" width="18%"> </td>
</tr>
<tr>
<td><img alt="" width="124" height="1" src="MsSpacer.gif"></td>
<td><img alt="" width="50" height="1" src="MsSpacer.gif"></td>
<td><img alt="" width="325" height="1" src="MsSpacer.gif"></td>
<td><img alt="" width="65" height="1" src="MsSpacer.gif"></td>
<td><img alt="" width="108" height="1" src="MsSpacer.gif"></td>
<td></td>
</tr>
</table>

</FORM>

</HEAD>
<body>
<SCRIPT>

function tax(){
{
if (document.number.taxper.value == null, document.number.taxper.value == "")
document.number.taxdone.value = (document.number.numb4.value);
else if (document.number.taxper.value != null, document.number.num1.value != "")


document.number.taxdone.value = (document.number.numb4.value * document.number.taxper.value %);
}
}

var numb1 = document.number.num1.value
var numb2 = document.number.num2.value




function grand(){
{
if (document.number.num1.value == null, document.number.num1.value == "")
document.number.numb4.value = ( "0.00");
else if (document.number.num1.value != null, document.number.num1.value != "")
document.number.numb4.value = ( document.number.num1.value * document.number.num2.value );
}
{
if (document.number.num1a.value == null, document.number.num1a.value == "")
document.number.numb4.value = ( parseInt(document.number.numb4.value));
else if (document.number.num1a.value != null, document.number.num1a.value != "")
document.number.numb4.value = ( parseInt(document.number.numb4.value) + document.number.num1a.value * document.number.num2a.value );
else if (document.number.numb4.value == null, document.number.numb4.value == "")
document.number.numb4.value = ( document.number.num1a.value * document.number.num2a.value + ".00");
}
{
if (document.number.num1b.value == null, document.number.num1b.value == "")
document.number.numb4.value = ( parseInt(document.number.numb4.value));
else if (document.number.numb4.value == null, document.number.numb4.value == "")
document.number.numb4.value = ( document.number.num1b.value * document.number.num2b.value + ".00");
else if (document.number.num1b.value != null, document.number.num1b.value != "")
document.number.numb4.value = ( parseInt(document.number.numb4.value) + document.number.num1b.value * document.number.num2b.value + ".00");
}
}

</SCRIPT>
</body>

Nate_Bro
09-08-2004, 07:31 PM
ok, i found this, but I'm not sure how to use it, I want the menus to close, when you click anywhere on the page. thanks again.

<script language=JavaScript>
function xpno() {{
if (document.all.XP1.style.visibility='visible')
document.all.XP1.style.visibility='hidden';
}{if (document.all.XP2.style.visibility='visible')
document.all.XP2.style.visibility='hidden';
}{if (document.all.XP5.style.visibility='visible')
document.all.XP5.style.visibility='hidden';
}{if (document.all.XP3.style.visibility='visible')
document.all.XP3.style.visibility='hidden';
}{if (document.all.XP4.style.visibility='visible')
document.all.XP4.style.visibility='hidden';
}
}

var message="";

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=xpno()

</script>