473,396 Members | 2,158 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,396 software developers and data experts.

Setting radio button state


I am trying to set the state of a radio button. I do not see what I am
doing wrong. Sorry, I am new at this.. I need another set of eyes to
look at this snip of code. I am trying to set the radio button with this
link of code:

echo 'SCRIPT language=JavaScript
setCheckedValue("'.$_SESSION['abbr_letter'].'");</SCRIPT>'; //?

<snip of code>

<?php
session_start();
if(!isset($_SESSION['abbr_letter'])) {
$_SESSION['abbr_letter'] = 'A';
}
require_once 'includes/config.inc.php';
require_once 'includes/header.inc.php';

if (xdebug_is_enabled())
echo "enable";
else
xdebug_enable();

//
// Start a Form
?>
<HTML>
<HEAD>
<link href="quotesCss.css" rel="stylesheet" type="text/css">
<SCRIPT TYPE="text/javascript">
<!--
// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(newValue) {
var len = document.author_abbrv.abbr_letter.length
for(var i = 0; i < len; i++)
{
document.author_abbrv.abbr_letter[i].checked = false;
if(document.author_abbrv.abbr_letter[i].value ==
newValue.toString())
{
document.author_abbrv.abbr_letter[i].checked = true;
}
}
}
-->
</SCRIPT>
</HEAD>
<b><FORM NAME="author_abbrv" method="POST" action="<?php echo
$_SERVER['PHP_SELF'];?>"></b>
<table>
<tr>
<td><input type="radio" name="abbr_letter" value="A"
onclick="submit()"A </td>
<td><input type="radio" name="abbr_letter" value="B"
onclick="submit()"B </td>
<td><input type="radio" name="abbr_letter" value="C"
onclick="submit()"C </td>
<td><input type="radio" name="abbr_letter" value="D"
onclick="submit()"D </td>
<td><input type="radio" name="abbr_letter" value="E"
onclick="submit()"E </td>
<td><input type="radio" name="abbr_letter" value="F"
onclick="submit()"F </td>
<td><input type="radio" name="abbr_letter" value="G"
onclick="submit()"G </td>
<td><input type="radio" name="abbr_letter" value="H"
onclick="submit()"H </td>
<td><input type="radio" name="abbr_letter" value="I"
onclick="submit()"I </td>
<td><input type="radio" name="abbr_letter" value="J"
onclick="submit()"J </td>
<td><input type="radio" name="abbr_letter" value="K"
onclick="submit()"K </td>
<td><input type="radio" name="abbr_letter" value="L"
onclick="submit()"L </td>
<td><input type="radio" name="abbr_letter" value="M"
onclick="submit()"M </td>
</tr>
<tr>
<td><input type="radio" name="abbr_letter" value="N"
onclick="submit()"N </td>
<td><input type="radio" name="abbr_letter" value="O"
onclick="submit()"O </td>
<td><input type="radio" name="abbr_letter" value="P"
onclick="submit()"P </td>
<td><input type="radio" name="abbr_letter" value="Q"
onclick="submit()"Q </td>
<td><input type="radio" name="abbr_letter" value="R"
onclick="submit()"R </td>
<td><input type="radio" name="abbr_letter" value="S"
onclick="submit()"S </td>
<td><input type="radio" name="abbr_letter" value="T"
onclick="submit()"T </td>
<td><input type="radio" name="abbr_letter" value="U"
onclick="submit()"U </td>
<td><input type="radio" name="abbr_letter" value="V"
onclick="submit()"V </td>
<td><input type="radio" name="abbr_letter" value="W"
onclick="submit()"W </td>
<td><input type="radio" name="abbr_letter" value="X"
onclick="submit()"X </td>
<td><input type="radio" name="abbr_letter" value="Y"
onclick="submit()"Y </td>
<td><input type="radio" name="abbr_letter" value="Z"
onclick="submit()"Z </td>
</tr>
</TABLE>
</FORM>
<b><FORM NAME="author" method="POST" action="<?php echo
$_SERVER['PHP_SELF'];?>"></b>
<SELECT NAME="author_pk" SIZE="20" COLS="10" onclick="submit()">

<?php
//
//Check for the first time pass
if( !isset($_POST['abbr_letter']) ) {
$_POST['abbr_letter'] = $_SESSION['abbr_letter'];
}
//
//Store the latest selected option to the Session var
$_SESSION['abbr_letter'] = $_POST['abbr_letter'];
echo 'SCRIPT language=JavaScript
setCheckedValue("'.$_SESSION['abbr_letter'].'");</SCRIPT>'; //?

--
Thanks in Advance... http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ____________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Nov 15 '06 #1
1 3204
IchBin wrote:
>
I am trying to set the state of a radio button. I do not see what I am
doing wrong. Sorry, I am new at this.. I need another set of eyes to
look at this snip of code. I am trying to set the radio button with this
link of code:

echo 'SCRIPT language=JavaScript
setCheckedValue("'.$_SESSION['abbr_letter'].'");</SCRIPT>'; //?
Hi,

The above line produces the following HTML:
SCRIPT language=JavaScript
setCheckedValue("'.$_SESSION['abbr_letter'].'");</SCRIPT>

EXCACTLY that goes to the browser.

You probably mean something like this:
echo '<SCRIPT type="text/javascript">';
echo 'setCheckedValue("'.$_SESSION['abbr_letter'].'");';
echo '</SCRIPT>';

(I haven't look at the rest for now because this line will cause JS to fail
from the start.)

Regards,
Erwin Moller

Nov 15 '06 #2

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

Similar topics

1
by: Jim Quast | last post by:
I have an ASP page and a CREGReports002.vbs file coded to export data to excel. I do this by building variables in a stored procedure. The ASP page has text boxes, list boxes, and radio buttons. ...
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
11
by: hygum | last post by:
I have combination of radio and select/input: http://sneleopard.dk/radio.html Is there a javascript which automatically sets radio 1, when the user does something with field 1, and automatically...
2
by: xazos79 | last post by:
Hi All, I've come across the problem of not being able to re-enable a radio button with javascript if its initial state has been disabled in the Page_Load() method of the code behind. Might i...
1
by: s.chelliah | last post by:
Hi, I am trying to use javascript, div tag and radio button to disable/enable a text box. It works fine in netscape and firefox, but in IE, the text box is not disabled when the user checks the...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
2
by: vajratkarviraj | last post by:
Hi, Am using Tkinter. Suppose I have 4 radio buttons (value 1,2,3 & 4) arranged in a single column. I want radio 2 to have a normal state and radio 4 to have a disabled state when radio 1 is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.