Find Jobs
Hire Freelancers

Add SELECT TAG to function with "Dynamic INPUT fields to auto submit all to mysql" jQuery

$10-30 USD

Completed
Posted about 8 years ago

$10-30 USD

Paid on delivery
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.'); }
Project ID: 10115644

About the project

10 proposals
Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
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 in 0 day
5.0 (25 reviews)
3.9
3.9
10 freelancers are bidding on average $27 USD for this job
User Avatar
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
$64 USD in 1 day
5.0 (1024 reviews)
8.7
8.7
User Avatar
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
$20 USD in 1 day
4.9 (228 reviews)
7.1
7.1
User Avatar
Hello It can be fixed right now Let me know if you are interested. Thank you ============================================
$45 USD in 1 day
4.8 (284 reviews)
6.9
6.9
User Avatar
A proposal has not yet been provided
$25 USD in 1 day
4.8 (5 reviews)
2.7
2.7
User Avatar
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
$25 USD in 1 day
0.0 (4 reviews)
0.0
0.0
User Avatar
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.
$30 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
A proposal has not yet been provided
$20 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of JAPAN
Bunkyoku, Japan
4.6
11
Payment method verified
Member since Feb 24, 2011

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.