PDA

View Full Version : having checkbox reset a page


stoutr5
11-16-2004, 12:24 AM
I am creating a db front end using php that displays the fields of a table with checkboxes to select fields to display in the query. I am trying to have another checkbox that will refresh the page with all existing information as well as a form to add a where clause to the underlying query. I would like another unchecked checkbox which if checked will display another form to generate more stipulations to the query. Here is a portion of the code that seems to do nothing when the checkbox is clicked.


function checkRefresh(value)
{
document.addwhereclause.submit();
}

<input type=\"checkbox\" name=\"addwhere\" value=\"addwhere\" onClick=\"javascript:checkRefresh()\"

the \'s are for php.
If anyone has any other ways of accomplishing this please indulge me.

thanks.

IKLOP
11-16-2004, 01:22 AM
You can't submit a checkbox. You would have to submit a form that contains the checkbox:function checkRefresh(value)
{
document.yourform.submit();
}

<form action=\"somepage.php\" method=\"POST\" name=\"yourform\">
<input type=\"checkbox\" name=\"addwhere\" value=\"addwhere\" onClick=\"javascript:checkRefresh()\"
</form>Though unless you have some other code that does stuff when the checkbox is checked, or I completely misunderstood your question, you might as well just make the checkbox a submit button.

stoutr5
11-16-2004, 08:46 PM
<HEAD>
function checkRefresh(value)
{
document.form1.submit();
}
</HEAD>
<BODY>
echo "<form method=\"POST\" name=\"form1\" action=\"$currentURL\">";
echo "<input type=\"checkbox\" name=\"addwhere\" value=\"addwhere\" onClick=\"javascript:checkRefresh()\"> Add Where Clause<br \>";
echo "</form>";
</BODY>

Here is where I defined my form and the javascript method, of course there is more code in the page. My goal is to use php to have the checkbox refresh the page when checked. This will insert a dropdown box with the fields in the table, a logical operator dropdown, a textbox, and another checkbox to add these allover again(including the previous one) with another checkbox. I am not sure if this is possible with a checkbox and was wondering if anyone knew. ( no luck googling ). With this code above nothing happens when I click the checkbox. Eventually I would like to allow the uncheck to remove the new section of the form.

I am not sure if this is even possible to implement this way.

Sorry for not explaining this very well earlier.
Thanks