Skip to content

Commit

Permalink
form update #2
Browse files Browse the repository at this point in the history
  • Loading branch information
vitadub committed Oct 29, 2017
1 parent f8d714b commit 66f8efd
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 244 deletions.
275 changes: 64 additions & 211 deletions sacferals/reportform.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ function formatPhone(phoneId) {
$("#"+phoneId).val(output);
$("#"+phoneId).get(0).setSelectionRange(startCursor, endCursor);
}

function validateReportCatColony(){
var colonyradio = document.getElementById("catcolonyradio");
var anotherradio = document.getElementById("interventionradio")
if(colonyradio.checked == true){
document.getElementById("zipcode").required = true;
document.getElementById("numberofcats").required = true;

document.getElementById("problemlocation").required = false;
document.getElementById("problemdescription").required = false;
}else if(anotherradio.checked==true){
document.getElementById("zipcode").required = false;
document.getElementById("numberofcats").required = false;

document.getElementById("problemlocation").required = true;
document.getElementById("problemdescription").required = true;
}
}
</script>

<?php
Expand Down Expand Up @@ -78,7 +60,6 @@ function validateReportCatColony(){
$setting = $_POST['setting'];
$comments = $_POST['comments'];


// Required field names
$required = array('firstname', 'email','zipcode');

Expand Down Expand Up @@ -137,66 +118,7 @@ function validateReportCatColony(){
{
print "<b>ERROR!!</b> Please fill out all fields";
}


}
else if(isset($_POST['submitintervention'])) //this processes after user submits data.
{
$FirstName = $_POST['firstname'];
$LastName = $_POST['lastname'];
$FullName = $FirstName." ".$LastName;
$Phone1 = $_POST['phone1'];
$Phone2 = $_POST['phone2'];

$ProblemLocation = $_POST['problemlocation'];
$ProblemDescription = $_POST['problemdescription'];
$MeasuresTaken = $_POST['measurestaken'];
$OthersWorking = $_POST['othersworking'];
$OtheresContact = $_POST['resolverscontact'];
$AdditionalComments = $_POST['additionalcomments'];

// Required field names
$required = array('problemlocation', 'problemdescription');

// Loop over field names, make sure each one exists and is not empty
$error = false;
foreach($required as $field)
{
if (empty($_POST[$field]))
{
$error = true;
}
}


if(!$error)
{ //display current table
$querycheck = "select * from FeralInterventionForm where problemlocation='$problemlocation'";

$resultcheck = mysqli_query($link, $querycheck); //link query to database

if(mysqli_num_rows($resultcheck) == 0)// magically check if this made a duplicate row
{ //if not process the insert query
$query = "insert into FeralInterventionForm values('', Now(), '$FullName', '$Phone1', '$Phone2',
'$ProblemLocation', '$ProblemDescription ', '$MeasuresTaken ', '$OthersWorking[0]', '$AdditionalComments', '$OthersContact',
'', '', '', '', '', '')";

//print $query;

mysqli_query($link, $query); //link query to database
echo "<script type='text/javascript'> document.location = 'formsubmitted.php'; </script>";
}
else
{
print "problem at '".$ProblemLocation."' has already been reported.";
}
}
else
{
print "<b>ERROR!!</b> Please fill out all fields";
}
}

?>

<!DOCTYPE html>
Expand Down Expand Up @@ -248,21 +170,6 @@ function validateReportCatColony(){
{
padding-left: 2em;
}
#imageToShow
{
display: none;
position: absolute;
}
#imageToShow1
{
display: none;
position: absolute;
}
#imageToShow2
{
display: none;
position: absolute;
}

/*error msg*/
.alert {
Expand Down Expand Up @@ -331,8 +238,8 @@ function validateReportCatColony(){
assist the colony you are reporting.</p>

<input type="checkbox" onclick="displayformdiv()"> I have read all the information required for filling out this form.</input><br>
<div id="formdiv" style="display: none">

<div id="formdiv" style="display: none; padding: 0 4vw">
<br><b><small><font color="red">* Required Fields</font></small></b><br><br>
<b>*First Name</b><br>
<input type="text" name="firstname" id="firstname" required><br><br>
Expand All @@ -348,131 +255,77 @@ function validateReportCatColony(){
<b>Secondary Phone</b><br>
<input type="tel" id="phone2" name="phone2" placeholder="1234567890" pattern=".{10,13}" maxlength="10" onkeyup="formatPhone('phone2');" /><br><br>

<b>*Report Type</b><br><!-- class='checkdisplay' -->
<input type="radio" name="problemtype[]" value="catcolony" id="catcolonyradio" onClick="displayForm(this); validateReportCatColony();"></input> Cat Colony<br>
<input type="radio" name="problemtype[]" value="intervention" id="interventionradio" onClick="displayForm(this); validateReportCatColony();"></input> Other Issues<br><br>
<b>Are you the primary caregiver/feeder?</b><br>
<input type="radio" name="caregiver[]" value="Yes" onclick="displayForm(this)"> Yes<br>
<input type="radio" name="caregiver[]" value="No" onclick="displayForm(this)"> No<br><br>
<div class='indent todisplay' id="feederID">
<b>Please clarify who is feeding it.</b><br>
<textarea rows="4" cols="50" name="feederdescription"></textarea><br><br>
</div>

<b>Colony Name</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">You can name your colony by the street name, your name <br>
or any name that will identify this group of cats</span>
</i><br>
<input type="text" name="colonyname" id="colonyname"><br><br>

<b>*Address of Cat Colony</b><br>
<input type="text" name="colonystreet" id="colonystreet" required><br><br>
<b>*Zip Code</b><br>
<input type="text" name="zipcode" id="zipcode" maxlength="5" required><span id="ziperror"></span><br><br>
<b>*City</b><br>
<span id="city_wrap"><input type="text" name="city" id="city" required></span><br><br>
<b>County</b><br>
<input type="text" name="county" id="county" readonly><br><br>
<b>State</b><br>
<input type="text" value="CA" readonly><br><br>

<!-- report colony -->
<div class='todisplay indent' id="catcolony1">
<b>Has anyone attempted to trap this colony?</b><br>
<input type="radio" name="trapattempt[]" value="Yes" id="trapattemtyes"> Yes<br>
<input type="radio" name="trapattempt[]" value="No" id="trapattemptno"> No<br><br>

<b>Are you the primary caregiver/feeder?</b><br>
<input type="radio" name="caregiver[]" value="Yes" onclick="displayForm(this)"> Yes<br>
<input type="radio" name="caregiver[]" value="No" onclick="displayForm(this)"> No<br><br>
<div class='indent todisplay' id="feederID">
<b>Please clarify who is feeding it.</b><br>
<textarea rows="4" cols="50" name="feederdescription"></textarea><br><br>
</div>
<b>*Approx # of Cats (including Kittens)</b><br>
<input type="number" name="numberofcats" min="1" max="99" id="numberofcats" required><br><br>

<b>Colony Name</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">You can name your colony by the street name, your name <br>
or any name that will identify this group of cats</span>
</i><br>
<input type="text" name="colonyname" id="colonyname"><br><br>

<b>*Address of Cat Colony</b><br>
<input type="text" name="colonystreet" id="colonystreet" required><br><br>
<b>*Zip Code</b><br>
<input type="text" name="zipcode" id="zipcode" maxlength="5"><span id="ziperror"></span><br><br>
<b>*City</b><br>
<span id="city_wrap"><input type="text" name="city" id="city" required></span><br><br>
<b>County</b><br>
<input type="text" name="county" id="county" readonly><br><br>
<b>State</b><br>
<input type="text" value="CA" readonly><br><br>

<b>Has anyone attempted to trap this colony?</b><br>
<input type="radio" name="trapattempt[]" value="Yes" id="trapattemtyes"> Yes<br>
<input type="radio" name="trapattempt[]" value="No" id="trapattemptno"> No<br><br>

<b>*Approx # of Cats (including Kittens)</b><br>
<input type="number" name="numberofcats" min="1" max="99" id="numberofcats"><br><br>

<b>Ear Tipped?</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">If the cat has the tip of one ear cut off or "tipped", this <br>means this
cat has already been trapped and is altered. <br>Release this cat immediately.</span>
</i><br>
<!-- <img id="imageToHover" src="images/question_mark.png" height= "18" width= "18" alt="hover me"/>
<img id="imageToShow" src="images/ears_tipped.png" alt="image to show"/><br> -->

<input type="radio" name="eartipped[]" value="Yes" id="eartippedyes"> Yes<br>
<input type="radio" name="eartipped[]" value="No" id="eartippedno"> No<br><br>

<b>Pregnant Cats?</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">Signs of a pregnant cat can include nesting <br> activities, vomiting,
and an enlarged abdomen.</span>
</i><br>
<!-- <img id="imageToHover1" src="images/question_mark1.png" height= "18" width= "18" alt="hover me"/>
<img id="imageToShow1" src="images/pregnant_cats.png" alt="image to show"/><br> -->

<input type="radio" name="pregnant[]" value="Yes" id="pregnantyes"> Yes<br>
<input type="radio" name="pregnant[]" value="No" id="pregnantno"> No<br><br>

<b>Injured Cats?</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">Signs of injured cats can include inflammation/swelling, <br>limping,
rapid breathing or other signs of stress, and blood.</span>
</i><br>
<!-- <img id="imageToHover2" src="images/question_mark2.png" height= "18" width= "18" alt="hover me"/>
<img id="imageToShow2" src="images/injured_cats.png" alt="image to show"/><br> -->

<input type="radio" name="recentlyinjured[]" value="Yes" id="recentlyinjuredinjuredyes" onClick="displayForm(this)"> Yes<br>
<input type="radio" name="recentlyinjured[]" value="No" id="recentlyinjuredinjuredno" onClick="displayForm(this)"> No<br><br>

<div class='indent todisplay' id="recentlyinjuredID">
<b>Describe Injury/Condition</b><br>
<textarea rows="4" cols="50" name="injurydescription"></textarea><br><br>
</div>

<b>What is the setting of this colony?</b><br>
<input type="radio" name="setting[]" value="Residential" id="residentialsetting"> Residential<br>
<input type="radio" name="setting[]" value="Commercial" id="commercialsetting"> Commercial<br>
<input type="radio" name="setting[]" value="Industrial"id="industrialsetting"> Industrial<br><br>

<b>Additional Comments</b><br>
<textarea rows="4" cols="50" name="comments"></textarea><br><br>

<input type="submit" name="submitcolony" value="Submit" > <!-- button itself -->
<b>Ear Tipped?</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">If the cat has the tip of one ear cut off or "tipped", this <br>means this
cat has already been trapped and is altered. <br>Release this cat immediately.</span>
</i><br>
<input type="radio" name="eartipped[]" value="Yes" id="eartippedyes"> Yes<br>
<input type="radio" name="eartipped[]" value="No" id="eartippedno"> No<br><br>

<b>Pregnant Cats?</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">Signs of a pregnant cat can include nesting <br> activities, vomiting,
and an enlarged abdomen.</span>
</i><br>
<input type="radio" name="pregnant[]" value="Yes" id="pregnantyes"> Yes<br>
<input type="radio" name="pregnant[]" value="No" id="pregnantno"> No<br><br>

<b>Injured Cats?</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">Signs of injured cats can include inflammation/swelling, <br>limping,
rapid breathing or other signs of stress, and blood.</span>
</i><br>
<input type="radio" name="recentlyinjured[]" value="Yes" id="recentlyinjuredinjuredyes" onClick="displayForm(this)"> Yes<br>
<input type="radio" name="recentlyinjured[]" value="No" id="recentlyinjuredinjuredno" onClick="displayForm(this)"> No<br><br>
<div class='indent todisplay' id="recentlyinjuredID">
<b>Describe Injury/Condition</b><br>
<textarea rows="4" cols="50" name="injurydescription"></textarea><br><br>
</div>

<!-- report problem -->
<div class='todisplay indent' id="intervention1">

<b>*Where Does the Feral Problem Exist?</b>
<i class="tooltip"><img src="images/blue_question_mark.png" height="13px"/>
<span class="tooltiptext">Enter identifying information <br> such as business or
apartment name, <br>address, cross streets, etc.</span>
</i><br>
<input type="text" name="problemlocation" id="problemlocation"><br><br>

<b>*Describe the problem that is occuring.</b><br>
<textarea rows="4" cols="50" name="problemdescription" id="problemdescription"></textarea><br><br>

<b>Describe the measures you have taken to fix the problem. (if any)</b><br>
<textarea rows="4" cols="50" name="measurestaken" id="measurestaken"></textarea><br><br>
<b>What is the setting of this colony?</b><br>
<input type="radio" name="setting[]" value="Residential" id="residentialsetting"> Residential<br>
<input type="radio" name="setting[]" value="Commercial" id="commercialsetting"> Commercial<br>
<input type="radio" name="setting[]" value="Industrial"id="industrialsetting"> Industrial<br><br>


<b>Are there other people working to resolve this problem?</b><br>
<input type="radio" name="othersworking[]" value="Yes" onClick="displayForm(this)"> Yes<br>
<input type="radio" name="othersworking[]" value="No" onClick="displayForm(this)"> No<br><br>

<div class='indent todisplay' id="othersworkingID">
<b>Please enter their names and contact information (phone/email)</b><br>
<textarea rows="4" cols="50" name="resolverscontact"></textarea><br><br>
</div>

<b>Additional Comments</b><br>
<textarea rows="4" cols="50" name="additionalcomments"></textarea><br><br>

<input type="submit" name="submitintervention" value="Submit"> <!-- button itself -->

</div>
<b>Additional Comments</b><br>
<textarea rows="4" cols="50" name="comments"></textarea><br><br>

<input type="submit" name="submitcolony" value="Submit" > <!-- button itself -->
</div>

</form>
<br>

Expand Down
50 changes: 17 additions & 33 deletions sacferals/script.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
$(document).ready(function ()
{
$('.checkdisplay').change(function ()
{
if (this.checked)
{
$(document).ready(function () {
$('.checkdisplay').change(function () {
if (this.checked)
$('.todisplay').fadeIn('fast');
}
else
{
else
$('.todisplay').fadeOut('fast');
}

});
});


function displayForm(c) {
if (c.value == "catcolony") {
jQuery('#catcolony1').fadeIn('fast');
jQuery('#intervention1').fadeOut('fast');
}
if (c.value == "intervention") {
jQuery('#intervention1').fadeIn('fast');
jQuery('#catcolony1').fadeOut('fast');
}

if (c.value == "Yes") {
if(c.name == "caregiver[]")
$("#feederID").fadeOut('fast');
if(c.name == "recentlyinjured[]")
jQuery('#recentlyinjuredID').fadeIn('fast');
if(c.name == "othersworking[]")
jQuery('#othersworkingID').fadeIn('fast');
if(c.name == "caregiver[]")
$("#feederID").fadeOut('fast');
if(c.name == "recentlyinjured[]")
$('#recentlyinjuredID').fadeIn('fast');
if(c.name == "othersworking[]")
$('#othersworkingID').fadeIn('fast');
}
if (c.value == "No") {
if(c.name == "caregiver[]")
$("#feederID").fadeIn('fast');
if(c.name == "recentlyinjured[]")
jQuery('#recentlyinjuredID').fadeOut('fast');
if(c.name == "othersworking[]")
jQuery('#othersworkingID').fadeOut('fast');
if (c.value == "No") {
if(c.name == "caregiver[]")
$("#feederID").fadeIn('fast');
if(c.name == "recentlyinjured[]")
$('#recentlyinjuredID').fadeOut('fast');
if(c.name == "othersworking[]")
$('#othersworkingID').fadeOut('fast');
}
};

0 comments on commit 66f8efd

Please sign in to comment.