Jump to content

user4245

Members
  • Posts

    6
  • Joined

  • Last visited

user4245's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for all your help everyone especially you cyberRobot. taquitosensei your code worked perfectly. Thank you so much!!
  2. Is there a way to make to checkbox react to the form value which is '.$color.' instead of the form name which is color. When I submit right now the code will check all of the colors fetched from the database but I want it to only check the individual color it clicked on. Here is my code. <?php $sidebar_color =""; $color_sql = mysql_query("SELECT *,COUNT(color) FROM products GROUP BY color ORDER BY color ASC"); $coCount = mysql_num_rows($color_sql); if ($coCount > 0) { while($row = mysql_fetch_array($color_sql)){ $color = $row["color"]; $sidebar_color .= '<div id="sidebar"><label><form action="?" method="REQUEST"><input type="checkbox" name="color" value="'.$color.'" onClick="submit(); return false" ' . (isset($_REQUEST['color']) ? 'checked="checked"' : '') . ' /><font size="-2"><a href="?color='.$color.'">'.$color.' ('.$row["COUNT(color)"].')</a></font></form></label></div>'; } } ?> My page will look something like this checkbox black (3) checkbox yellow (5) checkbox white (9) ... All the pages are different and vary all the time so I can't individually write out the colors in the form which is why I use '.$color.' I hope this is a little more clear. Any ideas?
  3. cyberRobot, Yes your code does the same as web_craftsman. Here is the updated code $sidebar_color .= '<div id="sidebar"><label><form action="?" method="REQUEST"><input type="checkbox" name="color" value="'.$color.'" onClick="submit();" ' . ((isset($_REQUEST['color'])) ? 'checked="checked"' : '') . ' /><font size="-2"><a href="?color='.$color.'">'.$color.' ('.$row["COUNT(color)"].')</a></font></form></label></div>'; I think you are right with the problem being that the variable is based on the "color" checkbox. Is there are way to make it based on '.$color.'? The '.$color.' is all the individual colors in the database. I hope that make sense.
  4. We are on the right track here. When I click the checkbox and the page refreshes all the checkboxes are checked now. How do I get it so just the type color I clicked on is checked? Any ideas? You are a huge help.
  5. Thank you for the response. What do you mean by "just change it to use the check box instead"?
  6. I am creating a clothing website and say for a color on the sidebar I want to be able to submit a form with 'onClick' that will refresh the page, which it already does but to keep the checkbox checked when doing so. Right now my code submits properly refreshing the page and displaying the right products but the check in the checkbox is gone. I need the check to stay. Here is my code $sidebar_color .= '<div id="sidebar"> <label><form action="?" method="REQUEST"> <input type="checkbox" name="color" value="'.$color.'" onClick="submit();" /> <font size="-2"> <a href="?color='.$color.'">'.$color.' ('.$row["COUNT(color)"].')</a> </font></form></label></div>'; Another problem is when the 'onClick="submit();"' refreshes the page and then I press back the checkbox is checked. I need it to be unchecked when I press back. Is this also possible? I have been at this for days and tried too many things to remember what I tried. I figure I need something like this if(isset($_REQUEST["color"])) echo "checked="checked"" but nothing seems to work for me. Anyone have any ideas how to fix the code?
×
×
  • 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.