You are here: Calling Javascript function in php script. « PHP Programming Language « IT news, forums, messages
Calling Javascript function in php script.

Posted by IchBin on 11/12/06 04:44

Not sure if I should post this to a javascript group or here. So I'll
try here first since most here mix both in this group. I am trying to
pass a php value into a JavaScript function that changes the state of a
particular radio button. The call is:

setCheckedValue("abbr_letter", $_SESSION['abbr_letter'])

Here is a snip of the code I am trying to get to work. Everything else
works except for the radio button being set. I just not sure if I have
things correct.

Any help would be appreciated.


session_start();
if(!isset($_SESSION['abbr_letter']))
$_SESSION['abbr_letter'] = 'A';

require_once 'includes/config.inc.php';
require_once 'includes/header.inc.php';
//
// Start a Form
$cssfile = 'quotes.css';
?>
<html>
<head>
<link href="<?php echo $cssfile; ?>" rel="stylesheet"
type="text/css">
<SCRIPT LANGUAGE=”JavaScript”>
setCheckedValue("abbr_letter", $_SESSION['abbr_letter'])

function setCheckedValue(radioObj, newValue) {
<?php print("radioObj, newValue: " . radioObj . " . " .
newValue) ?>
if(!radioObj)
return;
var radioLength = radioObj.length;
if(radioLength == undefined) {
radioObj.checked = (radioObj.value == newValue.toString());
return;
}
for(var i = 0; i < radioLength; i++) {
radioObj[i].checked = false;
if(radioObj[i].value == newValue.toString()) {
radioObj[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>

<br>
</FORM>
<b><FORM NAME="author" method="POST" action="<?php echo
$_SERVER['PHP_SELF'];?>"></b>
<SELECT NAME="author_pk" SIZE="20" COLS="10" onclick="submit()">

--
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-)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация