I have a filtering option in my Django application. The filtering is done by the choice (Name, location, designation EmployeeID, ..etc) selected on a drop down and the value entered in a text field. Now I wanted to validate when the user chooses EmployeeID from the drop down choice. If no value is entered in text box while selecting EmployeeID, then the form should not be submitted, and alert should be shown to enter some text. I created a js function for checking the field is empty or not, but its not working the way I wanted. I will paste my code here.
<form name="myform" id="myformid" method="POST" >
Filter By:
<select name="choices" id ="choicesId" style="color: black; background-color: #BDBDBD" >
<option value="Name">Name</option>
<option value="Designation" >Designation</option>
<option value="EmployeeID" id="empid">EmployeeID</option>
<option value="Project" >Project</option>
<option value="DateOfJoin" >Date Of Join</option>
<option value="location" >Location</option>
<option value="email">Email</option>
<option value="skills">Skills</option>
</select>
<input id="textField "type="text" name="textField" style="color: black; background-color: #BDBDBD" >
<input type="button" value="Go" onclick="isEmpty();">
</form>
<table id="employeeTable" class="tablesorter">
<thead><tr><th>Employee List <!-- <input type="image" src="/static/sort_asc.gif " height="12" name="sortAscend"> --> </th></tr></thead> <br>
<tbody>
{%for emp in emp_list.object_list%}
<tr>
<td><a STYLE="text-decoration:none" href ="http://10.1.0.90:8080/singleEmployee/{{emp.id}} "> {{ emp.userName }} </a></td>
</tr>
{%endfor%}
</tbody>
</table></h4>
</div><br><br>
<a STYLE="text-decoration:none" href="http://10.1.0.90:8080/createEmployee/ ">Create New Employee </a>
<script type="text/javascript">
function isEmpty(){
if ((document.myform.choices.selectedIndex.value==''))
{
alert(document.myform.choices.options[document.myform.choices.selectedIndex].id);
alert("Hi");
document.myform.choices.focus();
/*document.getElementById('employeeIDfield').innerHTML = 'Please fill this field';*/
return true;
}
else
{
alert("Data entered");
document.getElementById('myformid').action = "http://10.1.0.90:8080/filter/";
document.getElementById('myformid').submit();
return false;
}
}
</script>
What I could understand is the form is still getting submitted even after entering the Javascript function. The else condition is working for all process. Can somebody look into this problem and give me a solution? Please put a comment for any more clarity I should give. Any help would be appreciated.
Checked your code and if I understand your problem correctly, you want do that:
<form name="myform" id="myformid" method="POST" action="http://10.1.0.90:8080/filter/" onSubmit="javascript:return isEmpty();" >
Filter By:
<select name="choices" id ="choicesId" style="color: black; background-color: #BDBDBD" >
<option value="Name">Name</option>
<option value="Designation" >Designation</option>
<option value="EmployeeID" id="empid">EmployeeID</option>
<option value="Project" >Project</option>
<option value="DateOfJoin" >Date Of Join</option>
<option value="location" >Location</option>
<option value="email">Email</option>
<option value="skills">Skills</option>
</select>
<input id="textField" type="text" name="textField" style="color: black; background-color: #BDBDBD" value="" / >
<input type="submit" value="Go"/>
</form>
<table id="employeeTable" class="tablesorter">
<thead><tr><th>Employee List <!-- <input type="image" src="/static/sort_asc.gif " height="12" name="sortAscend"> --> </th></tr></thead> <br>
<tbody>
{%for emp in emp_list.object_list%}
<tr>
<td><a STYLE="text-decoration:none" href ="http://10.1.0.90:8080/singleEmployee/{{emp.id}} "> {{ emp.userName }} </a></td>
</tr>
{%endfor%}
</tbody>
</table></h4>
</div><br><br>
<a STYLE="text-decoration:none" href="http://10.1.0.90:8080/createEmployee/ ">Create New Employee </a>
<script type="text/javascript">
function isEmpty(){
var my_select = document.myform.choices;
var selected_index = my_select.selectedIndex;
var my_textfield = document.getElementById('textField');
if ((my_select[selected_index].value == 'EmployeeID') && ((my_textfield.value=='') || (my_textfield.value==null))) {
alert("Enter employee ID!");
my_textfield.focus();
return false;
}
else{
alert("Data entered");
return true;
}
}
</script>
Related
I am trying to show alert popup when the user didn't select any value from the dropdown
Here is my html :
<div id="reminder" class="popup-layout">
<form id="reminderForm" method="post">
<div class="modal followup-modal ui-draggable" id="reminderPopupdrag" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div id="errorInPopup" class="error displayInlineBlock"></div>
<div class="modal-header">
<h5 class="modal-title">select_followup</h5>
</div>
<div class="modal-body">
<table class="width100percent">
<tbody><tr>
<td>
<label><input type="radio" name="reminder" id="reminder-1" value="1" class="element full-width verticalAlignMiddle">close_with_reminder</label> </td>
<td class="textAlignRight">
<input type="text" id="reminderdate" name="reminderdate" class="marginRight5 displayNone">
</td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="reminderText" id="reminderText" value="" class="element displayNone width-full marginTop5" placeholder="add_remark_here"> </td>
</tr>
<tr>
<td colspan="2">
<label><input type="radio" name="reminder" id="reminder-2" value="2" class="element full-width">close_without_reminder</label> </td>
</tr>
<tr>
<td colspan="2">
<select name="reminderclosereason" id="reminderclosereason" class="element displayNone width100percent">
<option value="0">Select value</option>
<option value="6">Advertisements</option>
<option value="4">Another reason:</option>
<option value="17">Checking financial terms and conditions</option>
<option value="16">Company not leasable</option>
<option value="18">Future potential clients </option>
<option value="20">Offer is of vehicle type in which we do not do business</option>
<option value="12">Open application</option>
<option value="13">Order</option>
<option value="10">Other ticket already in progress</option>
<option value="11">Out of office reply </option>
<option value="50">Portal, ad removed, payment, offer withdrawn</option>
<option value="7">SPAM</option>
<option value="9">Unsubscribe MFO Mailing</option>
<option value="2">Vehicle/part is sold (indicate order number!)</option>
<option value="8">Vehicle/part not on stock (is looking for something else)</option>
<option value="1">Vehicles too expensive</option>
</select> </td>
</tr>
</tbody></table>
</div>
<div class="modal-footer">
<input type="submit" name="send" id="sendPreview" value="Save" class="defaultbutton displayNone"> </div>
</div>
</div>
</div>
</form>
</div>
And i have tried like this in my js function page:
var TICKET = {};
TICKET.preview = {
init: function () {
this.bindUI();
},
bindUI: function () {
var self = this;
$('#send').click(function () {
self.followupPopup();
});
$(document).on('change', 'input[name=reminder]', function () {
$('#sendPreview').show();
if ($(this).val() == 1) {
$('#reminderdate').datetimepicker({
showOn: "button",
buttonImage:vbdBaseUrl + '/images/calendar.png',
dateFormat:'dd-mm-yy',
timeFormat: 'HH:mm',
buttonImageOnly: true,
controlType: 'select',
showWeek: true,
firstDay: 1,
oneLine : true,
});
/**
* To display the tomorrows date and time as 8AM by default in datepicker input box.
*/
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
tomorrow.setHours(8);
tomorrow.setMinutes(0);
$('#reminderdate').datetimepicker('setDate', new Date(tomorrow));
$('#reminderText').show();
$('#reminderdate').show();
$('.ui-datepicker-trigger').show();
$('#reminderclosereason').hide();
$('#saveReminder').show();
return true;
}
$('#reminderText').hide();
$('#reminderdate').hide();
$('.ui-datepicker-trigger').hide();
$('#reminderclosereason').show();
$('#saveReminder').show();
});
$('#reminderForm').submit(function() {
if ('' == $('#reminderclosereason').val() && $('input[name=reminder]:checked').val()!= 1) {
$('#errorInPopup').html('please select close reason');
return false;
}
});
},
followupPopup: function () {
var request = BAS.ajax;
request.url = vbdBaseUrl + '/ticket/mail/follow-up';
request.method = 'POST';
request.data = {
ticketId : ticketId
}
request.ajaxRequest(function(response) {
$('#reminderPopup').html(response);
$('#reminderPopupdrag').draggable();
$('.popup-dragable').show();
});
}
};
$(function () {
TICKET.preview.init();
});
I have tried a lot of solution. but none of the things work in my case.
I haven't understood what wrong in this case. i am trying to check the condition if dropdown value not selected or drop-down value is 0 I would like to show alert
Can anyone help me
Thanks in advance.
It turns out the problem was simple - the alert IS working, it just doesn't come before the default behaviour of submit, which includes a page refresh.
If you prevent the default from happening, you can validate and then decide what to do from there. Attached is a working snippet.
$('#reminderForm').submit(function(e) {
e.preventDefault(); // Stop your form from submitting.
if ('0' === $('#reminderclosereason').val()) {
alert();
$('#errorInPopup').html('Please select close reason');
return false;
} else {
this.submit();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="reminder" class="popup-layout">
<form id="reminderForm" method="post">
<div class="modal followup-modal ui-draggable" id="reminderPopupdrag" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div id="errorInPopup" class="error displayInlineBlock"></div>
<div class="modal-header">
<h5 class="modal-title">select_followup</h5>
</div>
<div class="modal-body">
<table class="width100percent">
<tbody>
<tr>
<td>
<label><input type="radio" name="reminder" id="reminder-1" value="1" class="element full-width verticalAlignMiddle">close_with_reminder</label> </td>
<td class="textAlignRight">
<input type="text" id="reminderdate" name="reminderdate" class="marginRight5 displayNone">
</td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="reminderText" id="reminderText" value="" class="element displayNone width-full marginTop5" placeholder="add_remark_here"> </td>
</tr>
<tr>
<td colspan="2">
<label><input type="radio" name="reminder" id="reminder-2" value="2" class="element full-width">close_without_reminder</label> </td>
</tr>
<tr>
<td colspan="2">
<select name="reminderclosereason" id="reminderclosereason" class="element displayNone width100percent">
<option value="0">Select value</option>
<option value="6">Advertisements</option>
<option value="4">Another reason:</option>
<option value="17">Checking financial terms and conditions</option>
<option value="16">Company not leasable</option>
<option value="18">Future potential clients </option>
<option value="20">Offer is of vehicle type in which we do not do business</option>
<option value="12">Open application</option>
<option value="13">Order</option>
<option value="10">Other ticket already in progress</option>
<option value="11">Out of office reply </option>
<option value="50">Portal, ad removed, payment, offer withdrawn</option>
<option value="7">SPAM</option>
<option value="9">Unsubscribe MFO Mailing</option>
<option value="2">Vehicle/part is sold (indicate order number!)</option>
<option value="8">Vehicle/part not on stock (is looking for something else)</option>
<option value="1">Vehicles too expensive</option>
</select>
</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<input type="submit" name="send" id="sendPreview" value="Save" class="defaultbutton displayNone"> </div>
</div>
</div>
</div>
</form>
</div>
Try this, don't forget to Install Jquery :-)
if ($("#reminderclosereason option:selected").val() === "0") {
console.log("Hi");
}
Try this
$(document).ready(function(){
$('#reminderForm').submit(function(e) {
e.preventDefault();
if ($(document).find('#reminderclosereason').val())==0) {
alert('please select close reason');
$('#errorInPopup').html('please select close reason');
return false;
}
});
});
Don't forget to import jquery.js before you call this .
Hope this will help you
I have a form and user can dynamically add some text-feild to this form by clicking on dropdown and choosing what he wants to add.
How to post only these text feilds to php script using jquery
code:
<form id="sms_frm" name="sms_frm">
<tr>
<td width="17%"><label>Http URL</label></td>
<td >
<div class='input-group'>
<div class='input-group-addon'>
<i class='fa fa-television'></i>
</div>
<input type='text' class='form-control' id='smsurl' name='smsurl' >
</div>
</td>
<td></td>
</tr>
<tr id="element"></tr>
<tr>
<td>
<div class='input-group'>
<select name="sms_sel" class="form-control" style="margin: 10px" id="sms_sel">
<option value="username">UserName</option>
<option value="Password">Password</option>
<option value="APIKEY">APIKEY</option>
<option value="company">company</option>
<option value="Originator">Originator</option>
<option value="ServiceCode">ServiceCode</option>
<option value="sender">sender</option>
<option value="ServiceUrl">ServiceUrl</option>
<option value="ServicePassword">ServicePassword</option>
<option value="header">header</option>
<option value="OriginName">OriginName</option>
<option value="not">Not any of this</option>
</select>
</div>
</td>
<td><input type='text' class='form-control' id='vals' style="margin: 10px; float: right" name='vals' >
</td>
<td></td>
</tr>
</tbody></table>
this is ajax code to send text fields to php script but it not working
$(document).ready(function(){
$("#sms_frm").submit(function(event){
event.preventDefault(); //prevent default action
var arrays=new array();
var number = $(' input[type=text]');
$('#sms_frm input[type=text]').each(function () {
arrays.push(this);
});
var form_data = $(this).serialize(); //Encode form elements for submission
$.ajax({
url : "Save.php?id=sms_api",
type: 'post',
data : arrays
}).done(function(response){ //
$("#res").html(response);
});
});
});
</script>
if user choose sender for example new text field with id ='sender' and name ='sender' will be append
I don't want to send the select item with ajax
I only want text fields
Please try this code this may work...
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="sms_frm" name="sms_frm">
<table id="text-table">
<tr>
<td width="17%"><label>Http URL</label></td>
<td>
<div class='input-group'>
<div class='input-group-addon'><i class='fa fa-television'></i></div>
<input type='text' class='form-control' id='smsurl' name='smsurl' >
</div>
</td>
<td></td>
</tr>
<tr id="element"></tr>
<tr>
<td>
<div class='input-group'>
<select name="sms_sel" class="form-control" style="margin: 10px" id="sms_sel">
<option value="username">UserName</option>
<option value="Password">Password</option>
<option value="APIKEY">APIKEY</option>
<option value="company">company</option>
<option value="Originator">Originator</option>
<option value="ServiceCode">ServiceCode</option>
<option value="sender">sender</option>
<option value="ServiceUrl">ServiceUrl</option>
<option value="ServicePassword">ServicePassword</option>
<option value="header">header</option>
<option value="OriginName">OriginName</option>
<option value="not">Not any of this</option>
</select>
</div>
</td>
<td>
<input type='text' class='form-control' id='vals' style="margin: 10px; float: right" name='vals' >
</td>
<td>
</td>
</tr>
</table>
</form>
<script>
$('#sms_sel').change(function(e) {
var name=$(this).val();
var value=$('#vals').val();
$('<tr><td width="17%"><label>'+name+'</label></td><td><input type="text" sms="sms" class="form-control ss" id="'+name+'" name="'+name+'" value="'+value+'" ></td><td></td><tr>').insertBefore($(this).closest('tr'));
});
</script>
In your jQuery, select only text fields. You can do that in multiple ways -
By directly accessing the tag $('input[text]');
By assigning a class to every text field and then accessing based on that class like `$('.some-class');
By assigning a data-* rule and then accessing it like $('input').data(YOUR_RULE);
After selecting your text fields, submit your form.
I am using a javascript form with a server-side processor and I want to be able to have the form go to different emails based on the dropdown. I've gotten as far as I could based on other forms but I can't seem to get the emails to go through. I have added under the option tag on the email addresses for the choices and changed the value from an overall form email to "mailTo" () I am pretty sure this is where the issue is but I don't know how to fix it.
<form action="http://www.testsite.com/cgi-sys/formmail.pl" method="post" name="hgmailer">
<input type="hidden" name="recipient" value="mailTo">
<input type="hidden" name="subject" value="Website Consult Request">
<table width="100%" border="0" cellspacing="10px" cellpadding="10px">
<tbody>
<tr>
<td>Nearest Location*</td>
<td><select id="mailTo" name"mailTo">
<option value="option1#testsite.com">Option1</option>
<option value="option2#testsite.com">Option2</option>
<option value="option3#testsite.com">Option3</option>
<option value="option4#testsite.com">Option 4</option>
</select></td>
</tr>
</tbody>
</table><p> </p>
<input type="button" value="Schedule a Consultation" onclick="hgsubmit();" class="button">
<input type="hidden" name="redirect" value="thankyou.html">
</form>
EDIT - My final code did not save previously
What you can do is add a javascript function to change the value of "recipient" to the selected email like...
function changeVal() {
var selectedVal = document.getElementById("mailTo").value;
document.getElementById("recipient").value = selectedVal;
var test = document.getElementById("recipient").value;
//alert(test);
}
<form action="http://www.testsite.com/cgi-sys/formmail.pl" method="post" name="hgmailer">
<input type="hidden" name="recipient" id="recipient" value="mailTo">
<input type="hidden" name="subject" value="Website Consult Request">
<table width="100%" border="0" cellspacing="10px" cellpadding="10px">
<tbody>
<tr>
<td>Nearest Location*</td>
<td><select id="mailTo" name"mailTo" onchange="changeVal()">
<option value="option1#testsite.com">Option1</option>
<option value="option2#testsite.com">Option2</option>
<option value="option3#testsite.com">Option3</option>
<option value="option4#testsite.com">Option 4</option>
</select></td>
</tr>
</tbody>
</table><p> </p>
<input type="button" value="Schedule a Consultation" onclick="hgsubmit();" class="button">
<input type="hidden" name="redirect" value="thankyou.html">
</form>
...I added an alert that you can comment out if you would like to test. Also I did this in javascript and not Jquery as you only asked for that.
I am working on this form with several select elements with options Yes, No or Not applicable. It was required that whenever the user select yes option a separate date field appears next to it. I used HTML DOM document.getElementById("id").innerHTML for this date field. Everything went well but I was not able to pass the value of date to the form action page using POST method. Check this code:
<!-- javascript code -->
<script type="text/javascript">
function credit_check(name){
if(name=='YES')document.getElementById('div2').innerHTML='Date: <input type="date" name="credit_check_date" value= "mm/dd/yyyy" />';
else document.getElementById('div2').innerHTML='';
}
function employment_check(name){
if(name=='YES')document.getElementById('div3').innerHTML='Date: <input type="date" name="employment_check_date" value= "mm/dd/yyyy" />';
else document.getElementById('div3').innerHTML='';
}
</script>
</head>
<body>
<?php include("menu.inc"); ?>
<div id="main">
<table>
<form method="post" action="checkinfo.php">
<tr><td colspan=2><hr/><input type="hidden" name="consultant_id" value="<?php echo $consult_id; ?>"> </td>
</tr>
<tr align="center">
<td><b>Credit Check </b></td>
<td>
<select name="2" onchange="credit_check(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="YES">Yes</option>
<option value="NO">No</option>
<option value="NA">Not Applicable</option>
</select>
</td>
<td> <div id ="div2"> </div></td>
</tr>
<tr align="center">
<td><b>Employment Check :<font color='red'>*</font></b></td>
<td>
<select name="3" onchange="employment_check(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="YES">Yes</option>
<option value="NO">No</option>
<option value="NA">Not Applicable</option>
</select>
</td>
<td> <div id ="div3"> </div></td>
</tr>
</form>
</table>
Demo - Change function credit_check(name) to window.credit_check = function(name)
window.credit_check = function(name){
if(name=='YES') document.getElementById('div2').innerHTML='Date: <input type="date" name="credit_check_date" value= "mm/dd/yyyy" />';
else document.getElementById('div2').innerHTML='';
}
window.employment_check = function (name){
if(name=='YES') document.getElementById('div3').innerHTML='Date: <input type="date" name="employment_check_date" value= "mm/dd/yyyy" />';
else document.getElementById('div3').innerHTML='';
}
You're script wasn't loading properly,
Uncaught ReferenceError: credit_check is not defined in your console shows the error. The functions were not being defined. You can set your functions like above or reposition your code.
Put the inputs into the HTML at loading, then simply hide/show them.
<!-- javascript code -->
<script type="text/javascript">
function credit_check(name){
if(name=='YES')document.getElementById('div2').style.display = 'block';
else document.getElementById('div2').style.display = 'none';
}
function employment_check(name){
if(name=='YES')document.getElementById('div3').style.display = 'block';
else document.getElementById('div3').style.display = 'none';
}
</script>
</head>
<body>
<?php include("menu.inc"); ?>
<div id="main">
<table>
<form method="post" action="checkinfo.php">
<tr><td colspan=2><hr/><input type="hidden" name="consultant_id" value="<?php echo $consult_id; ?>"> </td>
</tr>
<tr align="center">
<td><b>Credit Check </b></td>
<td>
<select name="2" onchange="credit_check(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="YES">Yes</option>
<option value="NO">No</option>
<option value="NA">Not Applicable</option>
</select>
</td>
<td> <div id ="div2" style="display: none;">
Date: <input type="date" name="credit_check_date" value= "mm/dd/yyyy" />
</div></td>
</tr>
<tr align="center">
<td><b>Employment Check :<font color='red'>*</font></b></td>
<td>
<select name="3" onchange="employment_check(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="YES">Yes</option>
<option value="NO">No</option>
<option value="NA">Not Applicable</option>
</select>
</td>
<td> <div id ="div3" style="display: none;">
Date: <input type="date" name="employment_check_date" value= "mm/dd/yyyy" />
</div></td>
</tr>
</form>
</table>
It's also a good idea to check out jQuery, it makes this kind of stuff a lot easier to do.
Your code is already working. See http://jsfiddle.net/2wg4u6ut/
Make sure your JavaScript is in the head section of your document.
There were some minor issues in your formatting where the <form> tag belongs around the table.
You also were missing the submit button, but then it's already working.
I made a button which is showing and hiding div on click by using jQuery. But IE showing another extra div and rest of the browsers showing it properly.
<div class="hide-search-button">
<div class="l-f-w" id="locate">
<h1> Location </h1>
<input type="hidden" value="" id="loc_hidden"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h1>State</h1></td>
<td> <select onChange="selectCity(this.options[this.selectedIndex].value)" name="state_name" id="state_name">
<option value="Choose">Choose</option>
<?php
//connect with database
$sqlCountry="select DISTINCT state from sheet1
order by state asc ";
$resCountry=mysql_query($sqlCountry);
$checkCountry=mysql_num_rows($resCountry);
// fetch all country
while($rowCountry=mysql_fetch_array($resCountry)){
?>
<option value="<?php echo $rowCountry['state']?>">
<?php echo $rowCountry['state']?>
</option>
<?php
}
?>
</select></td>
</tr>
<tr>
<td><h1>Region</h1></td>
<td><select id="region_name" name="region_name"
onchange="selectState(this.options[this.selectedIndex].value)">
<option value="Choose">Choose</option>
</select>
</td>
</tr>
<!--<tr>
<td><h1>Suburb</h1></td>
<td><select id="suburb_name" name="suburb_name">
<option value="Choose">Choose</option>
</select></td>
</tr>-->
<tr>
<td><h1>Pin Code</h1></td>
<td> <input type="text"value=" " name="pin" id="pin"></td>
</tr>
</table>
<input type="hidden" value="2" name="searchform" />
<script>
function span_go()
{
//var locate = document.getElementById("menuSelection").innerHTML;
var service = document.getElementById("sertype").innerHTML;
//document.getElementById("locatetext").value = locate;
document.getElementById("servicetext").value = service;
//alert (service);
}
</script>
<input type="hidden" value="" id="servicetext" name="servicetext"/>
<?php /*?><a tabindex="0" href="menuContent.html" class="fg-button fg-button-icon-right ui-widget ui-state-default ui-corner-all" id="flyout"><div class="arrow_wrap"><span class="ui-icon ui-icon-triangle-1-s"></span> </div> <span id="menuSelection"> <?php echo $location ?></span></a><?php */?>
</div> <!-- location field wrapper ends here -->
<div class="service_type_wrap s-t-w">
<h1> Service Type </h1>
<select multiple="multiple" label="choose" style="margin-left:8px;" name="tex_value" id="worktype">
<option value="Long Day Care">Long Day Care</option>
<option value="Occasional Care">Occasional Care</option>
<option value="In Home Care">In Home Care</option>
<option value="Before School Care">Before School Care</option>
<option value="After School Care">After School Care</option>
<option value="Vacation">Vacation Care</option>
<option value="Special Care">Special Care</option>
<option value="Permanent / Contract">Permanent / Contract</option>
<option value="Part time">Part time</option>
</select>
</div> <!-- service type wrapper ends here -->
<div class="f-r-w" style="margin-left:10px;">
<h1> Filter Results </h1>
<select data-placeholder="<?php echo $sorting; ?>" class="chzn-select" style="width:200px;" tabindex="2"name="q_state" id="jobsort">
<option value="title">Sort by job title</option>
<option value="date">Sort by date</option>
</select>
</div> <!-- filter results wrapper ends here -->
<div class="go_button_wrap">
<input name="submit" type="submit" value="Go" id="custum_button" onclick="span_go();">
</div> <!-- go button ends here -->
</form>
</div>
JS:
$(document).ready(function() {
$("#button").toggle(function() {
//$(this).text('Hide Advance Search');
}, function() {
//$(this).text('Show Advance Search');
}).click(function(){
$(".hide-search-button").slideToggle("slow");
event.preventDefault();
});
});
Screenshot shown below:
Try to change click part of your code. You need to pass event object into the handler. In IE actually there is window.event object. Maybe it causes the issue:
.click(function(event) {
$(".hide-search-button").slideToggle("slow");
event.preventDefault();
});