Add SELECT TAG to function with "Dynamic INPUT fields to auto submit all to mysql" jQuery
$10-30 USD
Terminado
Publicado hace casi 8 años
$10-30 USD
Pagado a la entrega
This is an easy 15 min. work to make little extra income for java jquery expert.
Below is a script for automatically submitting forms to a MySQL database, but it doesn't work for <select> tags. How can I make this script work for those as well?
I have been struggling to include values from
<SELECT id="group1" name="group1">has over 100 options</select>
<SELECT id="group2" name="group2">has over 100 options</select>
along with other input fields to autosubmit as following
//script start
<script type="text/javascript">
// JQUERY: Plugin "autoSumbit"
(function($) {
[login to view URL] = function(options) {
return [login to view URL](this, function() {
// VARIABLES: Input-specific
var input = jQuery(this);
var column = [login to view URL]('name');
// VARIABLES: Form-specific
var form = [login to view URL]('form');
var method = [login to view URL]('method');
var action = [login to view URL]('action');
// VARIABLES: Where to update in database
var where_val = [login to view URL]('#where').val();
var where_col = [login to view URL]('#where').attr('name');
// ONBLUR: Dynamic value send through Ajax
[login to view URL]('blur', function(event) {
// Get latest value
var value = [login to view URL]();
if ([login to view URL]('type') == "checkbox")
{
if ([login to view URL]('checked') ){
value = 1;
}else{
value = 0;
}
}
// AJAX: Send values
[login to view URL]({
url: action,
type: method,
data: {
val: value,
col: column,
w_col: where_col,
w_val: where_val
},
cache: false,
timeout: 10000,
success: function(data) {
// Alert if update failed
if (data) {
alert(data);
}
// Load output into a P
else {
jQuery('#notice').text('Updated');
jQuery('#notice').fadeOut().fadeIn();
}
}
});
// Prevent normal submission of form
return false;
})
});
}
})(jQuery);
// JQUERY: Run .autoSubmit() on all INPUT fields within form
jQuery(function(){
jQuery('#ajax-form INPUT').autoSubmit();
});
</script>
<form id="ajax-form" class="autosubmit" method="POST" action="[login to view URL]">
<fieldset>
<div>
<div><input name="date" value="'.$Row['date'].'" /></div>
<div><input name="job" value="'.$Row['job'].'" /></div>
<div><input name="numb" value="'.$Row['numb'].'" /></div>
<div><input name="ri_amount" value="'.number_format($Row['ri_amount']).'" /></div>
<div><input name="ri_code" value="'.$Row['ri_code'].'" />
<div id="ri_codemenu">
<select id="group1" name="group1">
<option value="112" '. ((in_array('112', $ricode_array)) ? 'selected' : '').'>value1</option>
<option value="113" '. ((in_array('113', $ricode_array)) ? 'selected' : '').'>value2</option>
<option value="114" '. ((in_array('114', $ricode_array)) ? 'selected' : '').'>value3</option>
</select>
</div>
<div class="payamount"><input name="shi_amount" value="'.number_format($Row['shi_amount']).'" /></div>
<div class="shicode"><input name="shi_code" value="'.$Row['shi_code'].'" />
<div id="shi_codemenu">
<select id="group2" name="group2">
<option value="112" '. ((in_array('112', $shicode_array)) ? 'selected' : '').'>value1</option>
<option value="113" '. ((in_array('113', $shicode_array)) ? 'selected' : '').'>value2</option>
<option value="114" '. ((in_array('114', $shicode_array)) ? 'selected' : '').'>value3</option>
</select>
</div>
</div>
<div class="paytax"><input name="tax" value="'.$Row['tax'].'" /></div>
<div id="donebox"><input id="done'.$bi.'" type="checkbox" name="done" value="'.$Row['done'].'" '. ((in_array('1', $done_array)) ? 'checked' : '').'/><!--<label for="done'.$bi.'"></label>-->
</div>
<input id="where" type="hidden" name="id" value="'.$Row['id'].'" />
</fieldset>
</form>
// script end
//[login to view URL]
function clean($value){
return mysql_real_escape_string($value);
}
/* * FORM PARSING*/
// FORM: Variables were posted
if (count($_POST)){
// Prepare form variables for database
foreach($_POST as $column => $value)
${$column} = clean($value);
// Perform MySQL UPDATE
$result = mysql_query("UPDATE accountant SET ".$col."='".$val."'
WHERE ".$w_col."='".$w_val."'")
or die ('Unable to update row.');
}
Hi,
I think I have solution for your problem. Try add this one line "jQuery("#ajax-form SELECT").autoSubmit();" on your code like on example below.
// JQUERY: Run .autoSubmit() on all INPUT fields within form
jQuery(function(){
jQuery('#ajax-form INPUT').autoSubmit();
jQuery("#ajax-form SELECT").autoSubmit();
});
Regards,
Adam
$15 USD en 0 día
5,0 (25 comentarios)
3,9
3,9
10 freelancers están ofertando un promedio de $27 USD por este trabajo
Hello!
With 98% to 99% completion rate, 900+ successfully completed projects, and a 4.99 reputation (maximum possible, 5.0) (can be verified on my profile page https://www.freelancer.com/u/rajeshsonisl.html !!)... you can never go wrong choosing me :)
I am available to get started on your project right away. I look forward to your reply.
Thanks.
Kind Regards,
Rajesh Soni
Hello, is this code a snippet taken from a php string? I wont be able to run it correctly on my localhost, the best would be to send me the whole files in a rar file or letting me access the files on your own server otherwise I won't be able to identify the issue
Dear Prospect Hiring Manager.
Thank you for giving me a chance to bid on your project. i am a serious bidder here and i have already worked on a similar project before and can deliver as u have mentioned
I have checked your requirements.i have right skills to work on this assignment
my award = superb result = happy client. In a good partnership, good results happen. Good cooking makes good eating!BWe consider our client as our partner.
can u provide your email or sky-pe etc for further discussion about the project.
I am ready to discuss with you
with best Regards
I have proven skill on HTML, CSS, CSS3, JavaScript, jQuery, PHP, MySQL etc. So it think i'm not the good but i'm one the best fit for this particular project.