php - SUBMIT button not working with AJAX form -
i have had 2 static select boxes 1 of populated mysql database. these sending via ajax php script add items on list. form included submit button , of working fine.
i replaced box b ajax run dependant select box (select box b populated based on result select box a). in running fine too. but...... now submit button won't work , don't know why?
can show me ? (there lots of stray id's , classes have been playing around, please excuse these)
thankyou!
ajax populate dropdown select box b based on result select a
<script> $(document).ready(function($) { var list_select_id = 'a'; var list_target_id = 'b'; var initial_target_html = '<option value="">please select ...</option>'; //initial prompt target select $('#'+list_target_id).html(initial_target_html); //give target select prompt option $('#'+list_select_id).change(function(e) { //grab chosen value on first select list change var selectvalue = $(this).val(); //display 'loading' status in target select list $('#'+list_target_id).html('<option value="">loading...</option>'); if (selectvalue == "") { //display initial prompt in target select if blank value selected $('#'+list_target_id).html(initial_target_html); } else { //make ajax request, using selected value $.ajax({url: 'http://www.mypropertyviewing.com/client_order_form_v1.1/selector.php?svalue='+selectvalue, success: function(output) {$('#'+list_target_id).html(output);} }); } }); }); </script>
form select boxes b c
<form class="add-new-task" autocomplete="off" method="post" name="login_form"> <div> <select name="a" id="a"> <option value="">please select..</option> <option value="chemical">chemical</option> <option value="hardware">hardware</option> </select> <select name="b" id="b"></select> </div> </br> <div class="box300"> <p>select quantity</p> <select class="box250" name="c"> <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> </div> <input type='submit' class ="submitbox" value='add order' > </form>
ajax send output select boxes b & c php script (which working)
<script> // call add_task function add_task(); delete_task(); // call delete_task function function add_task() { $('.add-new-task').submit(function(){ var new_taska = $('.add-new-task select[name=b]').val(); var new_taskb = $('.add-new-task select[name=c]').val(); if(new_taska != '') {$.post('add-task.php', { senda: new_taska, sendb: new_taskb }, function( data ) {$(data).appendto('.task-list ul').hide().fadein(); delete_task(); }); } return false; }); } function delete_task() { $('.delete-button').click(function(){ var current_element = $(this); var id = $(this).attr('id'); $.post('delete-task.php', { task_id: id }, function() { current_element.parent().fadeout("fast", function() { $(this).remove(); }); }); }); } </script>
Comments
Post a Comment