Jquery selects

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Lonestarjack
Forum Commoner
Posts: 31
Joined: Tue Nov 11, 2008 7:13 am
Location: Texas

Jquery selects

Post by Lonestarjack »

I am trying to set/update a $_SESSION variable based on a radio button being clicked.

Code: Select all

<script type="text/javascript">
   $(document).ready (function(){
      $(':radio').change (function()
       	$(':radio[name=list]:nth(0)').attr('checked',true);
           {
              $_SESSION{'list'} = "Yes";
                } else {
              $_SESSION{'list'} = "No";
              };
      });


<input type="radio" name="list" value="Yes">Yes</input>
<input type="radio" name="list" checked value="No">No</input>

</script>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Jquery selects

Post by requinix »

Okay? And?
User avatar
Lonestarjack
Forum Commoner
Posts: 31
Joined: Tue Nov 11, 2008 7:13 am
Location: Texas

Re: Jquery selects

Post by Lonestarjack »

Gets an " Uncaught SyntaxError: Unexpected identifier"

$(':radio').change (function()

Sorry about that
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Jquery selects

Post by requinix »

You're missing a {. And an "if". And another set of })s.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Jquery selects

Post by twinedev »

and I don't see any PHP Code in that ;-)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Jquery selects

Post by requinix »

twinedev wrote:and I don't see any PHP Code in that ;-)
Ha, I completely passed over that.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Jquery selects

Post by Christopher »

Lonestarjack wrote:I am trying to set/update a $_SESSION variable based on a radio button being clicked.
You can't mix Javascript and PHP. You need to populate the Javascript with values when you generate it with PHP, or use an Ajax call to a PHP script to fetch data.
(#10850)
User avatar
Lonestarjack
Forum Commoner
Posts: 31
Joined: Tue Nov 11, 2008 7:13 am
Location: Texas

Re: Jquery selects

Post by Lonestarjack »

Thanks Christopher
I wrote a generic Ajax program that sets the session variables. Works great.
Post Reply