Greetings all.  I am trying to add some jquery code to a few modules I
am developing in Drupal 5.x.  I'm struggling to get up to speed with
jquery but so far i've been successful in what I have tried to do.
Until now.  If you would like to see the discussion I have already
started at Drupal it is at http://drupal.org/node/269197.

I have a very basic html page to outline what I am trying to do.  A
version of it is here:

http://www.whootis.com/dev/jquery.html


I have three radio buttons as part of a group.  I want to accomplish 2
things:
1> When the page loads, the state of the textfield (hidden or shown)
is determined based on what radio button has been set to be checked
and the textfield gets set.
2> When ever a user selects radio buttons R1 or R3 the textfield
remains hidden, and when the user clicks on R2 the textfield becomes
visible.

I have stumbled through various examples and gotten it to work
sometimes, and other times I can't get it to work at all.  Can someone
help me out here with some advice?

-Geoff

For reference here is the example page:

<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function()
            {
              var checkedValue = $
("[EMAIL PROTECTED]'myradiobutton']").val("r2");
              $(checkedValue).is(':checked') ? $("#txtfld").hide() : $
("#txtfld").show();

              $('input').click(function()
              {
                $
("[EMAIL PROTECTED]'myradiobutton']").val("r2").is(':checked') ? $
("#txtfld").show() : $("#txtfld").hide();
              });
            });
        </script>
    </head>

    <body>
        <form name="myform" action="#">
        <input type="radio" value="r1" name="myradiobutton"
checked="true" />1st<br />

        <input type="radio" value="r2" name="myradiobutton" />2nd<br /
>
        <select id="txtfld">
          <option>Milk</option>
          <option>Coffee</option>
          <option>Tea</option>
        </select><br />
        <input type="radio" value="r3" name="myradiobutton" />3rd<br /
>

        </form>
    </body>
</html>

Reply via email to