473,287 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Hide table using radio button

I have a table thats wrapped in a div tag, that when user selects 1 of 2
radio buttons it hides or shows table, this works ok.
But I want to set the table show hide on what the existing state of radio
buttons are on page load aswell, so if one button is allready selected then
the table is hidden else it is shown, can some help me with this,
Existing code below Regards Don.
'****************
<html>
<head>
</head>

<body>

<form method="POST" action="userinsert.asp" name="Form1">
<table border="0">
<tr>
<td nowrap class="labelheader">Purchase Type:</td>
<td nowrap class="labelheader" valign="middle">Use Credit Card: <input
type="radio" value="0" onfocus="showpurchase('purchasing');return true;"
name="chargetype">&nbsp;</td>
<td nowrap class="labelheader" valign="middle">Use Purchase Orders:
<input type="radio" name="chargetype" value="1"
onfocus="hidepurchase('purchasing');return false;" checked></td>
</tr>
</table>
<div id="purchasing" class="options" style="display: block; width: 377;
height: 26">
<table id="MyTable" border="0" width="39%">
<tr>
<td nowrap class="labelheader">This line should hide if Purchase
Order Selected</td>
</tr>
</table>
</div>
<table border="0" width="39%">
<tr>
<td width="39%" nowrap colspan="3"><input type="submit" value="Save
Details" name="btnSave" class="cmdflat" tabindex="24">
<input type="reset" value="Reset" name="B2" class="cmdflat"
tabindex="25"></td>
<td width="63%" nowrap class="labelheader">&nbsp;&nbsp; <b>Required
Fields (*)</b></td>
</tr>
</table>
</form>
<script type="text/JavaScript">
<!--
function showpurchase(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'block';
}
}
//-->

<!--
function hidepurchase(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'none';
}
else
{
document.getElementById(theTable).style.display = 'none';
}
}
//-->
</script>

</body>

</html>

'****************
Jul 23 '05 #1
1 11867
"Don Grover" <sp******@assoft.com.au> wrote in message
news:c5***********@otis.netspace.net.au...
I have a table thats wrapped in a div tag, that when user selects 1 of 2
radio buttons it hides or shows table, this works ok.
But I want to set the table show hide on what the existing state of radio
buttons are on page load aswell, so if one button is allready selected then the table is hidden else it is shown, can some help me with this,
Existing code below Regards Don.
'****************
<html>
<head>
</head>

<body>

<form method="POST" action="userinsert.asp" name="Form1">
<table border="0">
<tr>
<td nowrap class="labelheader">Purchase Type:</td>
<td nowrap class="labelheader" valign="middle">Use Credit Card: <input type="radio" value="0" onfocus="showpurchase('purchasing');return true;"
name="chargetype">&nbsp;</td>
<td nowrap class="labelheader" valign="middle">Use Purchase Orders:
<input type="radio" name="chargetype" value="1"
onfocus="hidepurchase('purchasing');return false;" checked></td>
</tr>
</table>
<div id="purchasing" class="options" style="display: block; width: 377;
height: 26">
<table id="MyTable" border="0" width="39%">
<tr>
<td nowrap class="labelheader">This line should hide if Purchase
Order Selected</td>
</tr>
</table>
</div>
<table border="0" width="39%">
<tr>
<td width="39%" nowrap colspan="3"><input type="submit" value="Save
Details" name="btnSave" class="cmdflat" tabindex="24">
<input type="reset" value="Reset" name="B2" class="cmdflat"
tabindex="25"></td>
<td width="63%" nowrap class="labelheader">&nbsp;&nbsp; <b>Required
Fields (*)</b></td>
</tr>
</table>
</form>
<script type="text/JavaScript">
<!--
function showpurchase(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'block';
}
}
//-->

<!--
function hidepurchase(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'none';
}
else
{
document.getElementById(theTable).style.display = 'none';
}
}
//-->
</script>

</body>

</html>

'****************


<html>
<head>
</head>

<body onload="setVisibility()">

<form method="POST" action="userinsert.asp" name="Form1">
<table border="0">
<tr>
<td nowrap class="labelheader">Purchase Type:</td>
<td nowrap class="labelheader" valign="middle">Use Credit Card: <input
type="radio" value="0" onfocus="showpurchase('purchasing');return true;"
name="chargetype">&nbsp;</td>
<td nowrap class="labelheader" valign="middle">Use Purchase Orders:
<input type="radio" name="chargetype" id="radioPurchase"
onfocus="hidepurchase('purchasing');return false;" checked></td>
</tr>
</table>
<div id="purchasing" class="options" style="display: block; width: 377;
height: 26">
<table id="MyTable" border="0" width="39%">
<tr>
<td nowrap class="labelheader">This line should hide if Purchase
Order Selected</td>
</tr>
</table>
</div>
<table border="0" width="39%">
<tr>
<td width="39%" nowrap colspan="3"><input type="submit" value="Save
Details" name="btnSave" class="cmdflat" tabindex="24">
<input type="reset" value="Reset" name="B2" class="cmdflat"
tabindex="25"></td>
<td width="63%" nowrap class="labelheader">&nbsp;&nbsp; <b>Required
Fields (*)</b></td>
</tr>
</table>
</form>
<script type="text/JavaScript">
<!--
function setVisibility()
{
var MyRadio = document.getElementById("radioPurchase")
MyRadio.value="1";
hidepurchase('purchasing');
}

function showpurchase(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'block';
}
}

function hidepurchase(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'none';
}
else
{
document.getElementById(theTable).style.display = 'none';
}
}
//-->
</script>

</body>

</html>
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
3
by: Owen Funkhouser | last post by:
I have a form with three radio options. And I have three buttons: <input type="submit" name="mainform_action" value="Edit Data"> <input type="submit" name="mainform_action" value="View Data">...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
5
by: Zambien | last post by:
Hi all, Here's my problem. I have tables that are using the menu/submenu idea for hiding rows. This works fine in IE (of course) and does show/hide correctly in netscape, but as soon as the...
2
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow {...
2
by: Advo | last post by:
Basically, ive got information in a table for the layout purposes, as its text for a questionnaire What i Need, is for instance when the user click a radio button, that information can be...
11
by: C.W.Holeman II | last post by:
I what to hide an input element and the following text. I have the selector for the input working and just need to grab the text following it. CSS: form{ display:table; text-align:center; }
1
by: stewdizzle | last post by:
I have a from with three radio buttons (same group) and three text boxes. The radio buttons give the user a choice of uploading one, two, or three images. Currently, I have the text boxes load as...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.