You can do it in javascript with..
document.form['yourformname'].reset();
or
<input type="button" name="reset_form" value="Reset Form"
onclick="this.form.reset();">
HTH,
Best,
Karl
On May 22, 2011, at 7:56 PM, Fahim Mohammad wrote:
Hi
I am trying to create a user interface for my MySQL database. I got
some
help earlier for my questions from some of the Php users on this
site. I am
now stuck at a point from where I have no idea how to proceed.
I created a form with 5-6 options some of them uses mysql results
based on
the previous options. I am using _GET and javascript to dynamically
show the
options as one may be dependent upon the other. I put the submit
button at
last. I want to go to a new page only after pressing the submit
button.
Since I am using autoSubmit in javaScript it directs to the new
page after I
select any of the option.
I know that this is possible but just dont know how to do it. I am
attaching the full code.
How to reset all the options by pressing the reset button once???.
Thanks a lot .
Php code:
[php]
<?php
$conn = mysql_connect('localhost', 'root', 'fahim');
$db = mysql_select_db('rugit',$conn);
if (!$db) die("Unable to connect to MySQL: " . mysql_error());
?>
<?php
$organism = $genomeVer = $queryType = $arrType = $arrTypeTarget =
null;
//declare vars
if(isset($_GET["organism"]) && is_string($_GET["organism"]))
{
$organism = $_GET["organism"];
}
if(isset($_GET["genomeVer"]) && is_string($_GET["genomeVer"]))
{
$genomeVer = $_GET["genomeVer"];
}
if(isset($_GET["queryType"]) && is_string($_GET["queryType"]))
{
$queryType = $_GET["queryType"];
}
if(isset($_GET["arrType"]) && is_string($_GET["arrType"]))
{
$arrType = $_GET["arrType"];
}
if(isset($_GET["arrTypeTarget"]) && is_string($_GET["arrTypeTarget"]))
{
$arrTypeTarget = $_GET["arrTypeTarget"];
}
?>
<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['theForm'];
formObject.submit();
}
</script>
<!-- Form tag -->
<form name="theForm" method="get" enctype="multipart/form-data">
<!--action
is left blank to enter all the options-->
<!-- Option 1: Select the organism -->
<select name="organism" onChange="autoSubmit();">
<option value="null">Select Organism</option>
<option value= "human" <?php if(strcmp($organism, "human") ==
0) echo
" selected"; ?>>human</option>
<option value= "mouse" <?php if(strcmp($organism, "mouse") ==
0) echo
" selected"; ?>>mouse</option>
<option value= "rat" <?php if(strcmp($organism,"rat") == 0)
echo "
selected"; ?>>rat</option>
</select> <br></br>
<!--Option 2: select the genome -->
<?php
//POPULATE DROP DOWN MENU FOR Genome version corresponding
to a
given organism
$sql = "SELECT genomeVer FROM organismGenomeVer WHERE
organism =
\"$organism\"";
//print("sql is $sql");
$result = mysql_query($sql,$conn);
//print("result is $result");
?>
<br>
<select name="genomeVer" onChange="autoSubmit();">
<option value="null">genomeVer</option>
<?php
while($row = mysql_fetch_array($result))
{
echo ("<option value=\"$row[0]\" " . ($genomeVer ==
$row["0"] ? " selected" : "") . ">$row[0]</option>");
}
mysql_free_result($result);
echo"</select>";
//print "\n\nselected genome version is $genomeVer\n\n\n\n";
?>
<!--Option 3: Radio button to select the query type -->
<br><br>
<input type="radio" value="idList" name="queryType" <?php if
($queryType == "idList") echo "checked"; ?> onclick="autoSubmit();" >
Identifier(s) as query <BR>
<input type="radio" value="seqList" name="queryType" <?php if
($queryType == "seqList") echo "checked"; ?> onclick="autoSubmit
();"> Fasta
Seq(s) as query
<BR></br>
<!--Option 4 (optional): Select input array Type -->
<?php
$query = strtolower("show tables like \"$organism%\"");
//print("query is $query");
$result = mysql_query($query, $conn);
$nRows = mysql_num_rows($result);
//print"nRows is $nRows";
if ($queryType == "idList")
{
?>
<br></br>
<select name="arrType" onChange="autoSubmit();">
<option value="null">Select arrType</option>
<option value="notSure" <?php if($arrType == "notSure") echo "
selected"; ?>>Not sure</option> <br></br>
<?php
while($row = mysql_fetch_array($result))
{
echo ("<option value=\"$row[0]\" " . ($arrType ==
$row["0"] ? " selected" : "") . ">$row[0]</option>");
}
echo"</select><br>";
mysql_free_result($result);
} //end if
?> <!--//end script for arrType -->
<!--Option 5 : Enter target array type -->
<?php
$query = strtolower("show tables like
\"$organism"."_"."$genomeVer%\"");
//print("query is $query");
$result = mysql_query($query, $conn);
$nRows = mysql_num_rows($result);
echo"<br></br>";
echo "Select target array:";
echo "<br></br><select name='arrTypeTarget[]' size='6'
multiple='multiple'><br>";
//print("query is $query");
//print("result is $result");
while($row = mysql_fetch_array($result))
{
echo ("<option value=\"$row[0]\" " .
($arrTypeTarget ==
$row["0"] ? " selected" : "") . ">$row[0]</option>");
}
echo"</select>";
$val = implode(", ", $_GET["arrTypeTarget"]);
echo"<br></br>";
//print("arrTypeTarget is: $val");
//mysql_free_result($result);
echo"<br></br>";
?>
<!-- Option 6: Text box to enter id list or fasta file -->
<textarea name=\"queryVal\" cols="40" rows="5" class=\"html-text-box
\">Enter
your query here...</textarea>
OR
<!-- Option 7: Upload File option -->
Select File: <input type='file' name='inpFile' size='10' />
</form>
<br />
<!-- Submit and reset button -->
<input type="submit" value="submit" name="submit" class="html-text-
box">
<input type="reset" value="Reset" class="html-text-box">
<style type="text/css">
textarea.html-text-box
{background-color:FFFFFF;background-image:url(http://);
background-repeat:no-repeat;background-attachment:fixed;border-
width:1;border-style:solid;
border-color:CC0000;font-family:Arial;font-size:10pt;color:000000;}
input.html-text-box
{background-color:99FF99;font-family:Arial;font-size:10pt;color:
3300FF;}
</style>
<?php
print ("\n$organism, $genomeVer, $queryType, $arrType");
?>
[/php]
Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php