Jump to content

How can I update values after load


Chanpa

Recommended Posts

Hey,

I'm making sort of a betting system for me and my friends and I've run into a bit of a snag.

The first part of it is fairly easy it is a simple 1 x 2 betting system like this:

<?php
$grp_a_t1 = array("team" => "Sverige", "pts" => 0);
$grp_a_t2 = array("team" => "Norge", "pts" => 0);
$grp_a_t3 = array("team" => "Danmark", "pts" => 0);
$grp_a_t4 = array("team" => "Finland", "pts" => 0);
?>
Round 1
<?php echo $grp_a_t1["team"]." - ".$grp_a_t2["team"]; ?>
<select name="grp_a_r1_m1">
<option>1</option>
<option>x</option>
<option>2</option>
</select>
<?php echo $grp_a_t3["team"]." - ".$grp_a_t4["team"]; ?>
<select name="grp_a_r1_m2">
<option>1</option>
<option>x</option>
<option>2</option>
</select>

Now what I want to know how to do (if possible) is to update the $team["pts"] depending on what you select. For instance if you choose "1" in the first match(name="grp_a_r1_m1"), I want to do: $grp_a_t1["pts"] += 3;

I would prefer it to update as soon as you select something, however I will settle for "at the press of a button" if it turns out it's to hard to have it update instantly.

I'm pretty sure I can't make this with PHP alone, so Currently I have done this:

<button id="grp_a_upd">Update this group</button>
<div id="grp_a">
<?php echo $grp_a_t1["team"]." with ".$grp_a_t1["pts"]; ?><br />
<?php echo $grp_a_t2["team"]." with ".$grp_a_t2["pts"]; ?><br />
<?php echo $grp_a_t3["team"]." with ".$grp_a_t3["pts"]; ?><br />
<?php echo $grp_a_t4["team"]." with ".$grp_a_t4["pts"]; ?><br />
</div>
<script language="javascript" type="text/javascript">
$('#grp_a_upd').click(function() {
	// Is it possible to update the variables here?
});
</script>

So as is infered in the code snippet above, is it possible to update php-variables with jQuery like that? If it is, how? Or do I need AJAX?

 

Thanks,

Chanpa

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.