By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,805 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,805 IT Pros & Developers. It's quick & easy.

php and Javascript call to change radio button

P: n/a
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
Share this Question
Share on Google+
10 Replies


P: n/a
VK

IchBin wrote:
I am trying to set the state of a radio button. I do not see what I am
doing wrong.
PHP is executed server-side; JavaScript is executed client-side. That
would be most helpful:
1) To know what exactly "wrong" in your case (radio button states do
not change; they change but on wrong buttons; browser crashes;
something else)
2) To see the page as it is at the moment of the JavaScript code
execution (thus served from the server to the user-agent). For this
generate HTML output out of your PHP (<http>...</http>) and post it
here.

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 #2

P: n/a
VK wrote:
IchBin wrote:
>I am trying to set the state of a radio button. I do not see what I am
doing wrong.

PHP is executed server-side; JavaScript is executed client-side. That
would be most helpful:
1) To know what exactly "wrong" in your case (radio button states do
not change; they change but on wrong buttons; browser crashes;
something else)
2) To see the page as it is at the moment of the JavaScript code
execution (thus served from the server to the user-agent). For this
generate HTML output out of your PHP (<http>...</http>) and post it
here.
Sorry all works, app wise, it is just the radio buttons do not stay
selected after selecting one once coming back from the server.. I do
post the button that is changed (Have echo'ed that value so I know I
trapped it, and trying to reset to that selected button.

The actual running code is here: http://ichbin.9999mb.com

Not sure how I can trap the the generated HTML code coming back from the
server..

Here is the entire script:

<?php
/**
*
http://localhost/quotes/quotesCss.ph...RT=tswebeditor
*
* @version $Id$
* @copyright 2006 weconsultants, http://weconsultants.phpnet.us
*/
session_start();
if(!isset($_SESSION['abbr_letter'])) {
$_SESSION['abbr_letter'] = 'A';
// echo 'setCheckedValue("abbr_letter",
"'.$_SESSION['abbr_letter'].'")';
}
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 lastest selected option to the Session var
$_SESSION['abbr_letter'] = $_POST['abbr_letter'];
echo 'SCRIPT language=JavaScript
setCheckedValue("'.$_SESSION['abbr_letter'].'");</SCRIPT>'; //?
//
//Setup for the database call for authors by first letter
$sqlcmd = $author_detail_select_by_Letter . $_POST['abbr_letter']
. $author_detail_orderBy;
if ($result = mysql_query($sqlcmd))
{
while ($row = mysql_fetch_object($result))
{
printf("<option value='%d'>%s %s, %s %s %s</option>n",
$row->id, $row->TITLE, $row->lastname,
$row->firstname, $row->middlename, $row->SUFFIX);
}
mysql_free_result($result);
}
else
{
die('Database Error: ' . $mysql->error);
exit;
}
?>
</SELECT>
<?php
//
// Add the list of top 20 authors
require_once 'top20.php';
?>
</FORM>

<BODY>
<?php
//
// This form uses the POST method, so process any post selections here
if( isset($_POST['author_pk']) )
{
//
// Log what author the user is looking for to the DB
include 'quoteLogging.php';
//
// Get all of the Quotes associated with this author
$sqlcmd = $author_detail_select . $_POST['author_pk'];
if ($author_detail = mysql_query($sqlcmd))
{
while( $row = mysql_fetch_object($author_detail) )
{
printf('<span style="font-weight: bold;">%s %s, %s %s
%s </span>' .
' %s <br<div style="margin-left: 80px;">%s '.
'<span style="font-weight: bold;"></div><br>'.
'<div style="margin-left: 80px;"><span
style="font-weight: bold;">' .
" Link: </span><a href='%s'Authors detail
information</a></span></div><br>",
$row->TITLE, $row->lastname,
$row->firstname, $row->middlename, $row->SUFFIX,
$row->BIRTHDEATH,$row->DESCRIPTION,$row->LINK);
}
}
else
{
die('Database Error: ' . mysql_error());
exit;
}
//
// Select the number of Quotes the selected author has.
$sqlcmd = $author_quote_number . $_POST['author_pk'];
if ($numberOfQuotes = mysql_query($sqlcmd))
{
$row = mysql_fetch_object($numberOfQuotes);
printf( '<div style="margin-left: 80px;"><span
style="font-weight: bold;">'.
'Number of Quotes: </span%s<br>',
number_format($row->COUNT) .
' </div>');
}
else
{
die('Database Error: ' . mysql_error());
exit;
}
//
//
$sqlcmd = $author_quote_select . $_POST['author_pk'] . " ORDER
BY quote;";
if ($resultSet = mysql_query($sqlcmd))
{
while( $row = mysql_fetch_object($resultSet))
{
printf('<span style="font-weight:
bold;background-color: white;">Quote:</span%s<br>',
$row->QUOTE);
if ($row->QUOTELITREF != '' )
{
printf( '<span style="font-weight: bold;
background-color: white;">'.
'Quote Reference:</span%s<br><br>',
$row->QUOTELITREF);
}
else
{
print('<br>');
}
}
}
else
{
mysql_free_result($result);
die('Database Error==' . mysql_error());
exit;
}
}
//
// Add a footer for all to know
require_once 'includes/footer.inc.php';
//
// Close DB
include 'includes/closedb.inc.php';
?>

--
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 #3

P: n/a
VK

IchBin wrote:
The actual running code is here: http://ichbin.9999mb.com
Not sure how I can trap the the generated HTML code coming back from the
server..
The URL (as seen in browser) *is* the HTML code coming back from the
server :-) This is what I meant, thank you.

In your case the page starts from <centertag and after a bunch of
other code (inscluding script) there is finally <htmlblock wrapped
into <div>. I'm very far of being a pedantical person here, but some
*very minimum* respect to basic programming rules has to be served in
any solution IMHO. Try do not get upset: but your pages are totally
dependant on the particular UA's error correction mechanics - this way
some generic advises are futile.
I just say that if your bring you pages into a descent form the problem
very well may disappear by itself. You may just try.

Nov 15 '06 #4

P: n/a

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>'; //?

<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-)
It appears that your PHP is generating the option list part of your
page, but not the radio buttons. When you reload the page, the radio
buttons are always going to load in their default state (unchecked as
NON of them say CHECKED).

Either have your PHP script generate the radio button output (and
output CHECKED for the radio button that corresponds to the abbr_letter
value) or generate some script that onload checks the abbr_letter value
and CHECKS the corresponding radio button.

That should do it.

Nov 15 '06 #5

P: n/a
VK wrote:
IchBin wrote:
>The actual running code is here: http://ichbin.9999mb.com
Not sure how I can trap the the generated HTML code coming back from the
server..

The URL (as seen in browser) *is* the HTML code coming back from the
server :-) This is what I meant, thank you.

In your case the page starts from <centertag and after a bunch of
other code (inscluding script) there is finally <htmlblock wrapped
into <div>. I'm very far of being a pedantical person here, but some
*very minimum* respect to basic programming rules has to be served in
any solution IMHO. Try do not get upset: but your pages are totally
dependant on the particular UA's error correction mechanics - this way
some generic advises are futile.
I just say that if your bring you pages into a descent form the problem
very well may disappear by itself. You may just try.
Sorry I am a Java programmer. I am new to Javascript\css\php. So you
would recommend that I rewrite this 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 #6

P: n/a
VK

IchBin wrote:
Sorry I am a Java programmer. I am new to Javascript\css\php. So you
would recommend that I rewrite this script?
I would recommend to make your server-side PHP to output a conventional
HTML page first. Skipping on such luxiry as doctype :-) the ouput would
be something like:

[[ Content-Type: text/html; charset=[YourCharset] ]]
<html>
<head>
<title>Your Title</head>
[[ Style data ]]
<script type="text/javascript">
[[ served generated script content ]]
</script>
</head>
<body>
[[body content ]]
<form>
[[ form content ]]
</form>
</body>
</html>

I don't give you 100% guarantee that your client-side script will start
to work as expected (only 90%) - but at least it will be possible to
make some reasonable analysis of what and why is not working.

Nov 16 '06 #7

P: n/a

IchBin wrote:
VK wrote:
IchBin wrote:
The actual running code is here: http://ichbin.9999mb.com
Not sure how I can trap the the generated HTML code coming back from the
server..
The URL (as seen in browser) *is* the HTML code coming back from the
server :-) This is what I meant, thank you.

In your case the page starts from <centertag and after a bunch of
other code (inscluding script) there is finally <htmlblock wrapped
into <div>. I'm very far of being a pedantical person here, but some
*very minimum* respect to basic programming rules has to be served in
any solution IMHO. Try do not get upset: but your pages are totally
dependant on the particular UA's error correction mechanics - this way
some generic advises are futile.
I just say that if your bring you pages into a descent form the problem
very well may disappear by itself. You may just try.
Sorry I am a Java programmer. I am new to Javascript\css\php. So you
would recommend that I rewrite this script?
I too develop in Java so if it were me I'd have a nice JSP page here :)

But to answer your question I think you will find it easier if you have
your button group code also generated by your PHP script. Use the same
logic that you use to determine which subgroup to load to determine
which radio button to write CHECKED next to...

Javascript can handle it, but it's not very graceful. AFAIK the only
way to access an individual radio button within a group is through an
array. Therefore to find it programmatically you'd have to have your
radio buttons return values like 0, 1, 2, 3 instead of A, B, C, D and
this would force you to do some converting on the server anyway.

Just my $.02
>
--
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 16 '06 #8

P: n/a
Tom Cole wrote:
IchBin wrote:
>VK wrote:
>>IchBin wrote:
The actual running code is here: http://ichbin.9999mb.com
Not sure how I can trap the the generated HTML code coming back from the
server..
The URL (as seen in browser) *is* the HTML code coming back from the
server :-) This is what I meant, thank you.

In your case the page starts from <centertag and after a bunch of
other code (inscluding script) there is finally <htmlblock wrapped
into <div>. I'm very far of being a pedantical person here, but some
*very minimum* respect to basic programming rules has to be served in
any solution IMHO. Try do not get upset: but your pages are totally
dependant on the particular UA's error correction mechanics - this way
some generic advises are futile.
I just say that if your bring you pages into a descent form the problem
very well may disappear by itself. You may just try.
Sorry I am a Java programmer. I am new to Javascript\css\php. So you
would recommend that I rewrite this script?

I too develop in Java so if it were me I'd have a nice JSP page here :)

But to answer your question I think you will find it easier if you have
your button group code also generated by your PHP script. Use the same
logic that you use to determine which subgroup to load to determine
which radio button to write CHECKED next to...

Javascript can handle it, but it's not very graceful. AFAIK the only
way to access an individual radio button within a group is through an
array. Therefore to find it programmatically you'd have to have your
radio buttons return values like 0, 1, 2, 3 instead of A, B, C, D and
this would force you to do some converting on the server anyway.

Just my $.02
>--
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-)
Tom, your $.02 is very much appreciated.. AS to writing it in JSP. Well,
I just wanted to try something different and expand my brain. They are
different animals and wanted to get handle around html\javascript\css
and php combined. It's just a little blurry for me now. I am hearing
what all the people are saying, that is, to have php process this on the
server.

--
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 16 '06 #9

P: n/a
VK wrote:
IchBin wrote:
>Sorry I am a Java programmer. I am new to Javascript\css\php. So you
would recommend that I rewrite this script?

I would recommend to make your server-side PHP to output a conventional
HTML page first. Skipping on such luxiry as doctype :-) the ouput would
be something like:

[[ Content-Type: text/html; charset=[YourCharset] ]]
<html>
<head>
<title>Your Title</head>
[[ Style data ]]
<script type="text/javascript">
[[ served generated script content ]]
</script>
</head>
<body>
[[body content ]]
<form>
[[ form content ]]
</form>
</body>
</html>

I don't give you 100% guarantee that your client-side script will start
to work as expected (only 90%) - but at least it will be possible to
make some reasonable analysis of what and why is not working.
Thank you for you suggestions. I will try to follow your advice.

--
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 16 '06 #10

P: n/a
Hi,
is this problem resolved in the mean time ?
Independant of missing Body-tag, I got some problems with the vector of
radio-type input tags: it did not work in all our applications. In the
actual application, I had to collect these elements by myself with a
code like
fy=document.getElementsByTagName("input");
and
if ( fy[j].checked && fy[j].type=="radio" &&
fy[j].name==name) {ii++;break;}

is this helping ? Whats your solution ?
Wolfgang

IchBin schrieb:
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-)
Dec 7 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.