Setting radio button state

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • IchBin

    #1

    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=JavaSc ript
    setCheckedValue ("'.$_SESSIO N['abbr_letter'].'");</SCRIPT>'; //?

    <snip of code>

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

    if (xdebug_is_enab led())
    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_let ter.length
    for(var i = 0; i < len; i++)
    {
    document.author _abbrv.abbr_let ter[i].checked = false;
    if(document.aut hor_abbrv.abbr_ letter[i].value ==
    newValue.toStri ng())
    {
    document.author _abbrv.abbr_let ter[i].checked = true;
    }
    }
    }
    -->
    </SCRIPT>
    </HEAD>
    <b><FORM NAME="author_ab brv" method="POST" action="<?php echo
    $_SERVER['PHP_SELF'];?>"></b>
    <table>
    <tr>
    <td><input type="radio" name="abbr_lett er" value="A"
    onclick="submit ()"A </td>
    <td><input type="radio" name="abbr_lett er" value="B"
    onclick="submit ()"B </td>
    <td><input type="radio" name="abbr_lett er" value="C"
    onclick="submit ()"C </td>
    <td><input type="radio" name="abbr_lett er" value="D"
    onclick="submit ()"D </td>
    <td><input type="radio" name="abbr_lett er" value="E"
    onclick="submit ()"E </td>
    <td><input type="radio" name="abbr_lett er" value="F"
    onclick="submit ()"F </td>
    <td><input type="radio" name="abbr_lett er" value="G"
    onclick="submit ()"G </td>
    <td><input type="radio" name="abbr_lett er" value="H"
    onclick="submit ()"H </td>
    <td><input type="radio" name="abbr_lett er" value="I"
    onclick="submit ()"I </td>
    <td><input type="radio" name="abbr_lett er" value="J"
    onclick="submit ()"J </td>
    <td><input type="radio" name="abbr_lett er" value="K"
    onclick="submit ()"K </td>
    <td><input type="radio" name="abbr_lett er" value="L"
    onclick="submit ()"L </td>
    <td><input type="radio" name="abbr_lett er" value="M"
    onclick="submit ()"M </td>
    </tr>
    <tr>
    <td><input type="radio" name="abbr_lett er" value="N"
    onclick="submit ()"N </td>
    <td><input type="radio" name="abbr_lett er" value="O"
    onclick="submit ()"O </td>
    <td><input type="radio" name="abbr_lett er" value="P"
    onclick="submit ()"P </td>
    <td><input type="radio" name="abbr_lett er" value="Q"
    onclick="submit ()"Q </td>
    <td><input type="radio" name="abbr_lett er" value="R"
    onclick="submit ()"R </td>
    <td><input type="radio" name="abbr_lett er" value="S"
    onclick="submit ()"S </td>
    <td><input type="radio" name="abbr_lett er" value="T"
    onclick="submit ()"T </td>
    <td><input type="radio" name="abbr_lett er" value="U"
    onclick="submit ()"U </td>
    <td><input type="radio" name="abbr_lett er" value="V"
    onclick="submit ()"V </td>
    <td><input type="radio" name="abbr_lett er" value="W"
    onclick="submit ()"W </td>
    <td><input type="radio" name="abbr_lett er" value="X"
    onclick="submit ()"X </td>
    <td><input type="radio" name="abbr_lett er" value="Y"
    onclick="submit ()"Y </td>
    <td><input type="radio" name="abbr_lett er" 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=JavaSc ript
    setCheckedValue ("'.$_SESSIO N['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-)
  • Erwin Moller

    #2
    Re: Setting radio button state

    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=JavaSc ript
    setCheckedValue ("'.$_SESSIO N['abbr_letter'].'");</SCRIPT>'; //?
    Hi,

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

    EXCACTLY that goes to the browser.

    You probably mean something like this:
    echo '<SCRIPT type="text/javascript">';
    echo 'setCheckedValu e("'.$_SESSIO N['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

    Comment

    Working...