Trying to set a boolean true onClick and another false
Moderator: General Moderators
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
Trying to set a boolean true onClick and another false
Well I am making 2 buttons
Dex & Str
You click Strength, it sets Str=true and then sets Dex=false
visa versa, how would I do this on a simple HTML button?
IE <input type='button' onclick='??'>
Dex & Str
You click Strength, it sets Str=true and then sets Dex=false
visa versa, how would I do this on a simple HTML button?
IE <input type='button' onclick='??'>
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
hmm
I just tried this, it didnt work
got an error on line 183
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\easyphp1-8\www\mythic aeons\homepig.php on line 183
hmmph? any ideas
Code: Select all
$dexBTN="<input type='button' name='dexBTN' value='Dexterity' onclick=$_SESSION['tstr']=false, $_SESSION['tdex']=true>";got an error on line 183
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\easyphp1-8\www\mythic aeons\homepig.php on line 183
hmmph? any ideas
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
how would I transport between them?
would it be better to use javascript for stat system?
(E.G you click new fight, it opens it up, and it calculates your str, blah blah and does def, each click,)
right now this is a glimpse of what im doing
thats for calculating dmg from both monsters, I have nearly 300 lines of code with only 2 stats done -.-
would it be better to use javascript for stat system?
(E.G you click new fight, it opens it up, and it calculates your str, blah blah and does def, each click,)
right now this is a glimpse of what im doing
Code: Select all
if ($_SESSION['mba=elf']==true)
{$_SESSION['dexcth']=rand($_SESSION['ML'], $_SESSION['dexlvl'] * 10);
$_SESSION['dexcthelf']=rand($_SESSION['MLelf'], $_SESSION['dexlvlelf'] * 10);
//damage above
$_SESSION['defptmelf']=rand($_SESSION['MLelf'], $_SESSION['deflvlelf'] * 10);
$_SESSION['defptm']=rand($_SESSION['ML'], $_SESSION['deflvl'] * 10);}
$_SESSION['defptmelf']=$_SESSION['defptmelf']/100;
$_SESSION['dexcthelf']=$_SESSION['dexcthelf']/100;
$_SESSION['dexcth']=$_SESSION['dexcth']/100;
$_SESSION['defptm']=$_SESSION['defptm']/100;
Last edited by Mythic Fr0st on Fri Dec 08, 2006 3:24 pm, edited 1 time in total.
The standard way is to post to a page (in my example, I just post to the page we're already on) and test the variables that were posted... then set your session variables accordingly.
Code: Select all
<?php
session_start();
if(isset($_POST['dexBTN']))
{
if($_POST['dexBTN'] == 'Dexterity'){
$_SESSION['tstr'] = false;
$_SESSION['tdex'] = true;
}
else
{
$_SESSION['tstr'] = true;
$_SESSION['tdex'] = false;
}
}
?>
<form method="post" action="#">
<input type='hidden' name='dexBTN' value='Dexterity'>
<input type="submit" value="Dexterity">
</form>
<form method="post" action="#">
<input type='hidden' name='dexBTN' value='UnDexterity'>
<input type="submit" value="UnDexterity">
</form>feyd | Please use
I haven't done this in awhile, but I'm pretty sure that you can hack together something it.
Good luck
-wyrmmage
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
yep, I do this:Code: Select all
<SCRIPT TYPE="text/javascript">
function changeStrength()
{
document.write("<? $_SESSION['str'] = 1; $_SESSION['dex'] = 0; ?>");
}
</SCRIPT>
<?
echo('
<FORM ACTION="somePage.php" METHOD="POST">
<input type='button' name='dexBTN' value='Dexterity' onclick=changeStrength()>";
</FORM>
');
?>Good luck
-wyrmmage
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]