/    Sign up×
Community /Pin to ProfileBookmark

checkbox event handling

I’d like to create a checkbox that, when checked, displays info from 1 specific MySQL query via PHP, and when unchecked, displays data from a different MySQL query via PHP.

So I have:
<INPUT TYPE=”checkbox” NAME=”maxSpecs” onClick=”???”><br><br>

and 2 working, different MySQL queries (abbreviated here):

$result = mysql_query(“SELECT * FROM laptops ORDER BY Price ASC LIMIT 0, 10;”) or die(mysql_error());

printf(“<table class=’results’>”);
while($row = mysql_fetch_array( $result )) {
printf(“<tr><td class=’lefcol’>%s %s %s</td><td><b>Price:</b> $%s</td></tr>”, $row[“Company”], $row[“Name”], $row[“ModelNum”], $row[“Price”]);
}
printf(“</table>”);

This, the 1st query, orders by “Price,” but I want to display info from a different query when the checkbox is checked. Is there a way to do this via Javascript onClick? Or is there a better way to organize and display this data?

Thanks for your help.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@sushiAug 26.2008 — I can get you started

[CODE]
<input type='checkbox' onclick='checkSpans();'/>
<span id='one'>First result</span>
<span id='two' class='hidden'>Second result</span>
[/CODE]


have checkSpans() check the checkbox. If it's on, then show ONE, and hide TWO, else show TWO and hide ONE.

happy coding!.
×

Success!

Help @snobblepopkin 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...