two dropdown and checkboxes on same page not working - php

I have to use same checkboxes and dropdowns according to the if condition ,---->
<div id="5" <? if($long_term_rental!=1) {?> style="display:none" <? } else {?>style="display:block" <? } ?>>
<table width="85%" >
<tr class="td3">
<td>City </td>
<td><select style="width:100px;" name="citylong" size="1" class="textfeild1" id="citylong">
<option <? if($citylong=="None")echo "selected='selected'";?>>None</option>
<option <? if($citylong=="Palm Springs")echo "selected='selected'";?>>Palm Springs</option>
<option <? if($citylong=="Cathedral City")echo "selected='selected'";?>>Cathedral City</option>
<option <? if($citylong=="Rancho Mirage")echo "selected='selected'";?>>Rancho Mirage</option>
<option <? if($citylong=="Palm Desert")echo "selected='selected'";?>>Palm Desert</option>
<option <? if($citylong=="La Quinta")echo "selected='selected'";?>>La Quinta</option>
<option <? if($citylong=="Indian Wells")echo "selected='selected'";?>>Indian Wells</option>
</select></td></tr>
<tr class="td2">
<td align="left">Upper/Lower/Town House/Single Story</td>
<td align="left"><select style="width:100px;" name="floorlong" size="1" class="textfeild1" id="floorlong">
<option <? if($floorlong=="None")echo "selected='selected'";?>>None</option>
<option <? if($floorlong=="Upper")echo "selected='selected'";?>>Upper</option>
<option <? if($floorlong=="Lower")echo "selected='selected'";?>>Lower</option>
<option <? if($floorlong=="TH")echo "selected='selected'";?>>TH</option>
<option <? if($floorlong=="Single Story")echo "selected='selected'";?>>Single Story</option>
</select></td>
</tr>
<tr class="td2">
<td> </td>
<td >Pets Allowed : </td>
<td ><input class="textfeild1" type="checkbox" name="petslong" id="petslong" value="Pets" <? if($petslong==1) echo "checked='checked'";?>/></td>
<td>Pool : </td>
<td><input class="textfeild1" type="checkbox" name="poollong" id="poollong" value="Pool" <? if($poollong==1) echo "checked='checked'";?>/></td>
<td align="right"> </td>
</tr>
<tr class="td2">
<td> </td>
<td>Jacuzzi : </td>
<td><input class="textfeild1" type="checkbox" name="jacuzzilong" id="jacuzzilong" value="Jacuzzi" <? if($jacuzzilong==1) echo "checked='checked'";?>/></td></div>
And on condition false display the below code---->
<div id="mylng" <? if($long_term_rental!=1) {?> style="display:block" <? } else {?>style="display:none" <? } ?>>
<table width="100%" >
<tr class="td3">
<td> </td>
<td>City </td>
<td><select style="width:100px;" name="city" size="1" class="textfeild1" id="city">
<option <? if($city=="None")echo "selected='selected'";?>>None</option>
<option <? if($city=="Palm Springs")echo "selected='selected'";?>>Palm Springs</option>
<option <? if($city=="Cathedral City")echo "selected='selected'";?>>Cathedral City</option>
<option <? if($city=="Rancho Mirage")echo "selected='selected'";?>>Rancho Mirage</option>
<option <? if($city=="Palm Desert")echo "selected='selected'";?>>Palm Desert</option>
<option <? if($city=="La Quinta")echo "selected='selected'";?>>La Quinta</option>
<option <? if($city=="Indian Wells")echo "selected='selected'";?>>Indian Wells</option>
</select></td>
<td align="right" style="width: 223px;">Upper/Lower/Town House/Single Story</td>
<td align="left"><select style="width:100px;" name="floor" size="1" class="textfeild1" id="floor">
<option <? if($floor=="None")echo "selected='selected'";?>>None</option>
<option <? if($floor=="Upper")echo "selected='selected'";?>>Upper</option>
<option <? if($floor=="Lower")echo "selected='selected'";?>>Lower</option>
<option <? if($floor=="TH")echo "selected='selected'";?>>TH</option>
<option <? if($floor=="Single Story")echo "selected='selected'";?>>Single Story</option>
</select></td></tr>
<tr class="td3">
<td> </td>
<td >Pets Allowed : </td>
<td ><input class="textfeild1" type="checkbox" name="pets" id="checkbox9" value="Pets" <? if($pets==1) echo "checked='checked'";?>/></td>
<td>Pool : </td>
<td><input class="textfeild1" type="checkbox" name="pool" id="checkbox8" value="Pool" <? if($pool==1) echo "checked='checked'";?>/></td>
<td align="right"> </td>
</tr>
<tr class="td3">
<td> </td>
<td>Jacuzzi : </td>
<td><input class="textfeild1" type="checkbox" name="jacuzzi" id="checkbox6" value="Jacuzzi" <? if($jacuzzi==1) echo "checked='checked'";?>/></td>
<td> </td>
<td> </td>
</tr>
</table></div>
But the code under <div id="5" is NOT WORKINg and the same code under <div id="mylng" is working PERFECTLY
Please help

at first you did not closed your
/tr
/table
at the end of
div id=5
please send us code with your form tag maybe your fault its on you HTML

Related

MSSQL procedure query return "Cannot insert the value NULL into column"

I have a form of 5 fields. when click on submit button it will fetch Amount against the fields from database MSSQL. Now when i fill form and submit it is giving an error. i have used MSSQL procedure query to execute it. please help me out i am in trouble now.
<div id="middle_pane">
<div>
<div id="inner_pane">
<div id="center_pane">
<div id="center_inner_pane">
<div class="txt_content">
<table width="385" height="200" style=" border:2px solid silver"
cellpadding="6px" cellspacing="0px" align="center" border="0">
<form method="POST" action="<?php bloginfo('url');?>/fedex-tariff">
<tr>
<td colspan="2" style="background:#0066FF; color:#FFFFFF;
fontsize:50px">Fedex Rate Card</td></tr>
<tr>
<td>Origin</td>
<td>
<select name="origin" id="origin" onChange="">
<option value="pakistan">Pakistan</option>
</select>
</td>
</tr>
<tr>
<td>Select Origin city </td>
<td>
<select name="city_id" id="city_id">
<option value="">--SELECT CITY--</option>
<?php
$city = "select * from branches";
$city_query = mssql_query($city);
while ($row_city = mssql_fetch_array($city_query)){
?>
<option value="<?php echo $row_city['name'];?>"> <?php echo
$row_city['name']; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>Select Destination </td>
<td>
<select name="country_id" id="country_id">
<option value="">--SELECT Destination--</option>
<?php
$service= "select * from country";
$service_query= mssql_query($service);
while ($row_service = mssql_fetch_array($service_query)){
?>
<option value="<?php echo $row_service['Name'];?>"> <?php
echo $row_service['Name']; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td> Selection of Weight </td>
<td>
<div id="wgt">
<input type="text" id="weight" name="weight" value=""
placeholder="weight...." required="">
</div>
</td>
</tr>
<tr>
<td>Select Your Service</td>
<td>
<select name="service_id" id="service_id">
<option value="">--SELECT--</option>
<?php
$service_type = "SELECT distinct ServiceTypeId from
dbo.IntlZoneCountry where ServiceTypeId IN ('FedEx Cash Tariff
Docs','FedEx Box','FedEx Student Package')";
$res_type = mssql_query($service_type);
$cnt_type = mssql_num_rows($res_type);
while($row_type = mssql_fetch_array($res_type)){
?>
<option value="<?php echo $row_type['ServiceTypeId'];?>"><?php
echo $row_type['ServiceTypeId'];?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td> <input type="submit" value="Calculate" name="submit"
class="btn"></td>
</tr>
</form>
<table width="385" style=" border:2px solid silver"
cellpadding="6px" cellspacing="0px" align="center" border="0">
<tr>
<td>
<?php
if(isset($_POST['submit']))
{
$city_id = $_POST['city_id'];
$country_id = $_POST['country_id'];
$service_id = $_POST['service_id'];
$weight_id = $_POST['weight'];
if(empty($city_id) || empty($country_id) || empty($service_id) ||
empty($weight_id)){
?><center><?php echo "Please filled all the fields first.";?>
</center>
<?php
}
else{
$s = "[SP_UpdateCNPrice_Int_Tariff]
'$weight_id','$city_id','$country_id','$service_id'";
$result = mssql_query($s);
while($row = mssql_fetch_assoc($result)){
?>
</td>
</tr>
<tr style="background:#00CFFF; color:blue;">
<td>
<center>
<font size="3">
<?php
$val = $row['amount'];
$gst = $row['gst'];
echo "<strong>"."Rate : "."$".""." ".$val.$gst;
?>
</font>
</center>
</td>
</tr>
<tr style="background:#00CFFF; color:blue;">
<td><center> All Rates are Exclusive of 16% GST + 23% fuel
Charges (FSC).</center> </td>
</tr>
<?php
}
}
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
MSSQL Procedure Screenshot
Front Display of Website

select option selected in loop

I am trying to get the value from a selectbox. The form is placed multiple times on my page with a php loop (that's why I use classes instead of id's).
<html>
<body>
<table>
<form class="lesmaker">
<tr>
<td colspan="5">
<select name="type" class="type">
<option value="open">Open vraag</option>
<option value="info">Informatie</option>
<option value="discussie">Klassikaal</option>
<option value="meerkeuze" selected="selected">Meerkeuze</option>
</select>
</td>
</tr>
<tr>
<td colspan="5">
<select name="media" class="media">
<?php foreach($images as $image){if(substr($image,0,1) != '.'){ ?>
<option style="background-image:url(<?=$d_images.$image?>)" value="<?=$image?>" <?php if($r_media== $image) echo 'selected="selected"'; ?>><?=$image?></option>
<?php }} ?>
</select>
</td>
</tr>
</form>
</table>
<table>
<form class="lesmaker">
<tr>
<td colspan="5">
<select name="type" class="type">
<option value="open">Open vraag</option>
<option value="info">Informatie</option>
<option value="discussie">Klassikaal</option>
<option value="meerkeuze" selected="selected">Meerkeuze</option>
</select>
</td>
</tr>
<tr>
<td colspan="5">
<select name="media" class="media">
<?php foreach($images as $image){if(substr($image,0,1) != '.'){ ?>
<option style="background-image:url(<?=$d_images.$image?>)" value="<?=$image?>" <?php if($r_media== $image) echo 'selected="selected"'; ?>><?=$image?></option>
<?php }} ?>
</select>
</td>
</tr>
</form>
</table>
</body>
</html>
With jQuery I am trying to get the selected option.
$(function(){
$('.lesmaker').each(function() {
console.log($(this).find('.type').val());
});
});
The code above is not working. How do I need to do this?
$(function() {
$('.lesmaker').each(function() {
console.log($(this).find('table tr td').find('.type').val());
});
});
You need to change your HTML to following:
<form class="lesmaker">
<table>
<tr>
<td colspan="5">
<select name="type" class="type">
<option value="open">Open vraag</option>
<option value="info">Informatie</option>
<option value="discussie">Klassikaal</option>
<option value="meerkeuze" selected="selected">Meerkeuze</option>
</select>
</td>
</tr>
</table>
</form>
form needs to be either outside of table or inside of td :)
$(function() {
$('.type').each(function() {
console.log($('option:selected', this).val());
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table>
<form class="lesmaker">
<tr>
<td colspan="5">
<select name="type" class="type">
<option value="open">Open vraag</option>
<option value="info">Informatie</option>
<option value="discussie">Klassikaal</option>
<option value="meerkeuze" selected="selected">Meerkeuze</option>
</select>
</td>
</tr>
<tr>
<td colspan="5">
<select name="type" class="type">
<option value="open">Open vraag</option>
<option value="info">Informatie</option>
<option value="discussie" selected="selected">Klassikaal</option>
<option value="meerkeuze" >Meerkeuze</option>
</select>
</td>
</tr>
<tr>
<td colspan="5">
<select name="type" class="type">
<option value="open">Open vraag</option>
<option value="info" selected="selected">Informatie</option>
<option value="discussie" >Klassikaal</option>
<option value="meerkeuze" >Meerkeuze</option>
</select>
</td>
</tr>
</form>
</table>
Just use the class of select and use $('option:selected', this).val()

Echo data in same form after submitting

I have a simple html form, which is included in a Spry Tabbed Panel.
So, i would like to know, is it possible to submit that form, and only that form in the Panel, and then echo the submitted data back in the correct fields.
The echo part is not a problem doing it on a different page, or redirect after submitting, but my issue comes in with the other forms that should/can not be cleared if this one is submitted.
A hint in the right direction would be greatly appreciated!
Thank you in advance.
see code below:
(i know that the form action should not direct to a different file, but that is just how I've been using it until now...)
<form action="caller_upd.php" method="post" name="contact" >
<table width="200" border="0">
<?php
$_SESSION['uid'] = $uid;
?>
<tr>
<td width="68">Title</td>
<td width="4">:</td>
<td width="144"><select name="title" id="title">
<option selected="selected" disabled="disabled"</option>
<option value="Mr">Mr</option>
<option value="Ms">Ms</option>
<option value="Dr">Dr</option>
</select></td>
<td width="6"> </td>
<td width="53">Number</td>
<td width="3">:</td>
<td width="301"><input style="color:rgb(255,0,0);" autofocus="autofocus" type="text" name="contactnr" id="contactnr" /></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input type="text" name="fname" id="fname" /></td>
<td> </td>
<td>Surname</td>
<td>:</td>
<td><input type="text" name="sname" id="sname" /></td>
</tr>
<tr>
<td>Nature of Call</td>
<td>:</td>
<td><select name="type" id="type">
<option disabled="disabled" selected="selected"></option>
<option value="Domestic">Domestic</option>
<option value="MVA">MVA</option>
<option value="Assult">Assult</option>
<option value="Padestrian">Padestrian</option>
<option value="Transfer">Transfer</option>
<option value="Private">Private</option>
</select></td>
<td> </td>
<td>Nr of Patients:</td>
<td>:</td>
<td><select name="nop" id="nop">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10+">10+</option>
</select></td>
</tr>
<tr>
<td>Location</td>
<td><label for="location"></label></td>
<td colspan="5"><input name="location" type="text" id="location" size="50" /> <?php if (!empty($location)){ ?>Show Map<?php } else { } ; ?></td>
</tr>
<tr>
<td>Comments:</td>
<td colspan="6"><textarea name="comment" id="comment" cols="70" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="7" class="form"><input type="submit" name="submit" id="submit" value="Update" /></td>
</tr>
</table>
</form>
Check if the post value exists, and if so either select the option or put the value in the input element...
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="contact" >
<table width="200" border="0">
<tr>
<td width="68">Title</td>
<td width="4">:</td>
<td width="144"><select name="title" id="title">
<option value="Mr" <?php if(isset($_POST['title']) && $_POST['title'] == "Mr") echo "selected"; ?>>Mr</option>
<option value="Ms" <?php if(isset($_POST['title']) && $_POST['title'] == "Ms") echo "selected"; ?>>Ms</option>
<option value="Dr" <?php if(isset($_POST['title']) && $_POST['title'] == "Dr") echo "selected"; ?>>Dr</option>
</select></td>
<td width="6"> </td>
<td width="53">Number</td>
<td width="3">:</td>
<td width="301"><input style="color:rgb(255,0,0);" autofocus="autofocus" type="text" name="contactnr" id="contactnr" value="<?php if(isset($_POST['contactnr'])) echo $_POST['contactnr']; ?>" /></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input type="text" name="fname" id="fname" value="<?php if(isset($_POST['fname'])) echo $_POST['fname']; ?>" /></td>
<td> </td>
<td>Surname</td>
<td>:</td>
<td><input type="text" name="sname" id="sname" value="<?php if(isset($_POST['sname'])) echo $_POST['sname']; ?>" /></td>
</tr>
...
</table>
</form>

display form main page and action page in wordpress for plugin frontend side user

I have created one plugin which inserts vehicles to DB table,displays vehicles at admin side from that table.One page is for settings of that plugin.admin side of plugin is mostly complete.now i want to display a form for taxi booking.when user submit that form in action page, i want to display google map with locations and distance with payment option.i googled it but not found best way.How sholud i create plugin front side?from where should I start?can anyone suggest me?
this is the form that i want to display at front side
<form name="book_form" id="book_form" action="" method="POST">
<!--<input type="hidden" name="action" value="tBM_taxibooking_save_booking" />-->
<table>
<tbody>
<tr>
<th>Select Location Points On Google Map</th>
<td>
<select name="location_points" id="location_points">
<option value="points">Points</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</td>
</tr>
<tr>
<th>First Address Point</th>
<td><input type="text" name="first_point" id="first_point"></td>
</tr>
<tr>
<th>Second Address Point</th>
<td><input type="text" name="second_point" id="second_point"></td>
</tr>
<tr>
<th>Third Address Point</th>
<td><input type="text" name="third_point" id="third_point"></td>
</tr>
<tr>
<th>Fourth Address Point</th>
<td><input type="text" name="fourth_point" id="fourth_point"></td>
</tr>
<tr>
<th>Adult Seats</th>
<td>
<select name="adult" id="adult">
<option value="Adult Seats">Adult Seats</option>
<?php
$i=1;
for($i=1;$i<=10;$i++)
{ echo'<option value="'.$i.'">'.$i.'</option>'; }
?>
</select>
</td>
</tr>
<tr>
<th>Child Seats</th>
<td>
<select name="child" id="child">
<option value="Child Seats">Child Seats</option>
<?php
$i=1;
for($i=1;$i<=10;$i++)
{ echo'<option value="'.$i.'">'.$i.'</option>'; }
?>
</select>
</td>
</tr>
<tr>
<th>Suitcases</th>
<td>
<select name="suitcases" id="suitcases">
<option value="Suitcases">Suitcases</option>
<?php
$i=1;
for($i=1;$i<=50;$i++)
{ echo'<option value="'.$i.'">'.$i.'</option>'; }
?>
</select>
</td>
</tr>
<tr>
<th>Select Vehicle</th>
<td>
<select name="vehicle" id="vehicle">
<option value="vehicles">Select Vehicle</option>
<?php
while($row=mysql_fetch_assoc($results))
{
echo'<option value="'.$row['vechicle_id'].'">'.$row['vechicle_title'].'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<th>Date</th>
<td><input type="text" name="date" id="date"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Get Map & Distance" id="submit" name="submit"></td>
</tr>
</tbody>
</table>
</form>

JavaScript to Post PHP action

My below code is posting at both times when the checkbox is checked or not checked. When its not checked I am getting alert and then posting. But when checked its posting automatically.
I need JavaScript to post the form when Submit button is clicked and checkbox should be kept checked. Else it should just provide me an alert. But unfortunately the page is reloading even when keeping the checkbox unchecked and using submit button.
My code is
<script type="text/javascript">
function check()
{
if(document.getElementById("privacy").checked == true)
{
document.print.submit();
}
else{
alert('Please read and accept our privacy statments to proceed.');
};
}
</script>
</head>
<body>
<form id="print" action="printfile.php">
<div id="express">
<table width="800">
<tr>
<td colspan="2"><span style="color:#FF0000; font-size:26px;">Express Application</span></td>
</tr>
<tr>
<td width="300"> </td>
<td width="500"> </td>
</tr>
<tr>
<td>First Name (Required) </td>
<td><input name="firstname" type="text" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Last Name </td>
<td><input name="lastname" type="text" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Email (Required) </td>
<td><input name="email" type="text" id="email" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Purpose of finance (Required) </td>
<td><select name="purpose" id="purpose">
<option selected="selected">Home Loan</option>
<option>Refinance</option>
<option>Investment Loan</option>
<option>Debit Consolidation</option>
<option>Others</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Your deposit amount </td>
<td><input name="depositamount" type="text" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Amount you need to borrow? </td>
<td><input name="borrowamount" type="text" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Brief description of purpose of <br />
finance (Required) <br />
<br />
<br />
<br />
<br />
<br /></td>
<td><textarea name="purposedesc" cols="60" rows="10" id="purposedesc"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Application Type<br />
<br /></td>
<td><label>
<input type="radio" name="apptype" value="Single" onclick="document.getElementById('singleapp').style.visibility = 'visible'; document.getElementById('jointapp').style.visibility = 'hidden';" />
Single Application</label>
<br />
<label>
<input type="radio" name="apptype" value="Joint" onclick="document.getElementById('singleapp').style.visibility = 'visible'; document.getElementById('jointapp').style.visibility = 'visible';" />
Joint Application</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><input name="privacy" type="checkbox" id="privacy" value="checkbox" />
Privacy Act (Required) <br />
<br />
I have read the Privacy Act 1988 (as Amended) and understand that by selecting the submit button I/we authorise Best Aussie Broker to act on my/our behalf and manage personal information in relation to this application. </td>
</tr>
</table>
<br />
Last step then we will get all listed Australian vendors to fight it out for your best deal.<br />
<br />
<table width="800" border="0" style="">
<tr>
<td width="400">
<div id="singleapp">
<table width="400" border="0">
<tr>
<td colspan="2" bgcolor="#333300"><span class="style1">Your application </span></td>
</tr>
<tr>
<td width="150"> </td>
<td width="240"> </td>
</tr>
<tr>
<td>Date of Birth</td>
<td><select name="day1" id="day1">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select name="month1" id="month1">
<option selected="selected">Jan</option>
<option>Feb</option>
<option>Mar</option>
<option>Apl</option>
<option>May</option>
<option>Jun</option>
<option>Jul</option>
<option>Aug</option>
<option>Sep</option>
<option>Oct</option>
<option>Nov</option>
<option>Dec</option>
</select>
<input name="year1" type="text" id="year1" style="padding:1.2px;" size="8" maxlength="4" /> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Address</td>
<td><input name="address1" type="text" id="address1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Suburb</td>
<td><input name="suburb1" type="text" id="suburb1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>PostCode</td>
<td><input name="postcode1" type="text" id="postcode1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>State</td>
<td><select name="state1" id="state1">
<option value="Victoria" selected="selected">VIC</option>
<option value="New South Wales">NSW</option>
<option value="QueensLand">QLD</option>
<option value="South Australia">SA</option>
<option value="Western Australia">WA</option>
<option value="Tasmania">TAS</option>
<option value="New Zeland">NZ</option>
<option value="Other">Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Best contact </td>
<td><select name="phone1" id="phone1">
<option>Phone</option>
<option>Email</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Phone number </td>
<td><input name="number1" type="text" id="number1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Marital status </td>
<td><select name="maried1" id="maried1">
<option>Single</option>
<option>Married</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Residential status </td>
<td><select name="rstatus1" id="rstatus1">
<option selected="selected">Renting</option>
<option>Home Owner</option>
<option>Home Mortgaged</option>
<option>Board</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Children/dependents</td>
<td><select name="childs1" id="childs1">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6 or more">6 or more</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Net income </td>
<td><input name="netincome1" type="text" id="netincome1" size="10"/>
per
<select name="months1" id="months1">
<option>Month</option>
<option>Year</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Current employer </td>
<td><input name="cemployer1" type="text" id="cemployer1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Time at this<br />
employer </td>
<td> Years
<select name="years1" id="years1">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="More">More</option>
</select>
Months
<select name="emonth1" id="emonth1">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" value="Submit my Application" onclick="check();" /></td>
</tr>
</table>
</div>
</td>
<td width="400">
<div id="jointapp">
<table width="400" border="0">
<tr>
<td colspan="2" bgcolor="#333300"><span class="style1">Your partner's application </span></td>
</tr>
<tr>
<td width="150"> </td>
<td width="240"> </td>
</tr>
<tr>
<td>Date of Birth</td>
<td><select name="day11" id="day11">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select name="month11" id="month11">
<option selected="selected">Jan</option>
<option>Feb</option>
<option>Mar</option>
<option>Apl</option>
<option>May</option>
<option>Jun</option>
<option>Jul</option>
<option>Aug</option>
<option>Sep</option>
<option>Oct</option>
<option>Nov</option>
<option>Dec</option>
</select>
<input name="year2" type="text" size="8" maxlength="4" style="padding:1.2px;" /> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Address</td>
<td><input name="address12" type="text" id="address12" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Suburb</td>
<td><input name="suburb12" type="text" id="suburb12" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>PostCode</td>
<td><input name="postcode12" type="text" id="postcode12" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>State</td>
<td><select name="state12" id="state12">
<option value="Victoria" selected="selected">VIC</option>
<option value="New South Wales">NSW</option>
<option value="QueensLand">QLD</option>
<option value="South Australia">SA</option>
<option value="Western Australia">WA</option>
<option value="Tasmania">TAS</option>
<option value="New Zeland">NZ</option>
<option value="Other">Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Best contact </td>
<td><select name="phone11" id="phone11">
<option>Phone</option>
<option>Email</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Phone number </td>
<td><input name="number11" type="text" id="number11" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Marital status </td>
<td><select name="married12" id="married12">
<option>Single</option>
<option>Married</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Residential status </td>
<td><select name="rstatus12" id="rstatus12">
<option selected="selected">Renting</option>
<option>Home Owner</option>
<option>Home Mortgaged</option>
<option>Board</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Children/dependents</td>
<td><select name="childs12" id="childs12">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6 or more">6 or more</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Net income </td>
<td><input name="netincome12" type="text" id="netincome12" size="10"/>
per
<select name="months12" id="months12">
<option>Month</option>
<option>Year</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Current employer </td>
<td><input name="cemployer12" type="text" id="cemployer12" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Time at this<br />
employer </td>
<td> Years
<select name="years12" id="years12">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="More">More</option>
</select>
Months
<select name="emonths12" id="emonths12">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select></td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
</div>
</td>
</tr>
</table>
<p><br />
<br />
<center>
</center>
<br />
</p>
</div>
</form>
With the inline event handler syntax you're using it is easiest to return false so the default action (the submitting) isn't executed:
<input name="submit"
type="submit"
value="Submit my Application"
onclick="check(); return false;" />
You need to make the submit return false, otherwise it will just do the regular thing a form does when you click submit.
if(document.getElementById("privacy").checked == true)
{
document.print.submit();
}
else
{
alert('Please read and accept our privacy statments to proceed.');
return false;
}
Technically as it will be submitting anyway. You could just get it to check and only intercept if it is not checked.
if(document.getElementById("privacy").checked == false)
{
alert('Please read and accept our privacy statments to proceed.');
return false;
}
Also add return to the submit onclick (link #AndreKR said)
<input name="submit" type="submit" value="Submit my Application" onclick="return check();" />

Categories