/    Sign up×
Community /Pin to ProfileBookmark

php enable checkbox

I have been trying to figure out how to enable a checkbox. I know how to do it in Javascript, but I’m wanting to do it in php.
I know it is possible, I just can’t seem to get it right.

[code=php]
<?php
//<!– <SCRIPT LANGUAGE=”JavaScript”> –>
//<!–
function codename() {

// if(document.formname.checkboxname.checked)
if ($checkboxname = checked)
{
// document.formname.textname.disabled = false;
$textname = false;
}

else
{
//document.formname.textname.disabled=true;
$textname = true;
}
}

//–>
// <!– </SCRIPT> –>
?>

[/code]

and the HTML is:

[code=php]
<body>

<form action=”” method=”” name=”formname”>

<input type=”text” disabled size=”10″ name=”textname”>

<input type=”checkbox” onclick=”codename()” name=”checkboxname” value=”ON”>

<input type=”submit” value=”Add”>

<input type=”reset” value=”Clear”>

</form>
</body>
[/code]

I know the php code there does not work. But I know that there is a way to make a function to enable the checkbox. I’m just not seeing it.
I’ve looked all over for a simple PHP script that I could use. Web search was useless.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@SheldonMar 18.2006 — You cant do it with php unless you refresh the page? PHP is server side, it doesent interact with the browser with out refreshing the page.
Copy linkTweet thisAlerts:
@anothenauthorMar 18.2006 — You cant do it with php unless you refresh the page? PHP is server side, it doesent interact with the browser with out refreshing the page.[/QUOTE]
Oh, duh.

Oh well, I was thinking that maybe functions were active when the page was loaded.

From what you are saying, the function is only available on the server side. That makes sense.
×

Success!

Help @anothen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...