logo
down
shadow

Add input field button for drop down box with data from the database


Add input field button for drop down box with data from the database

By : SoloKing
Date : November 18 2020, 01:01 AM
it helps some times I believe the main problem you are experiencing is related to PHP placing non-escaped single quotation marks in your JavaScript string (which is delimited with single quotes).
Note: the methods you are using for database queries in PHP are generally considered deprecated, but I left them in here in case your version of PHP only supports functional queries.
code :
$(wrapper).append('<div><label for="NoTelefon[]">No.Telefon</label>'+
    '<input type="text" name="NoTelefon[]" id="NoTelefon[]" class="required input_field">'+
    '<?php
        $sql  = "SELECT KodLokasi, NamaLokasi FROM kodlokasi";
        $result = mysql_query($sql);
        echo "<select name=\'KodLokasi[]\' id=\'KodLokasi[]\' class=\'input_field\' required /><option></option>";
        while($kod = mysql_fetch_array($result)){
            echo "<option value=\'".$kod['KodLokasi']."\'>" .$kod['NamaLokasi']. "</OPTION>";
        }
        echo "</select>";
    ?>'+
    '<a href="#" class="remove_field">Batal</a></div>'); //add input box


Share : facebook icon twitter icon
Data from MYSQL Database straight to Input fields, depending on what is written in first input field

Data from MYSQL Database straight to Input fields, depending on what is written in first input field


By : Hunter W
Date : March 29 2020, 07:55 AM
To fix this issue Not sure if I understand your question correctly but I'm assuming you wish to pull company info from table 1 and user info from table 2. If so you can use join - assuming you have some sort of identifier field in between the two... I.e. company_id. company names could work but this would not be good approach. 1. company names can be misspelled / uper-lower case issues / indexing performance. For the example sake lets join two tables on company name.
code :
"SELECT t1.user_login,t1.user_password,t1.user_name,t1.user_email FROM Table_1 t1 LEFT JOIN Table_2 t2 ON t2.user_company = t1.company_name WHERE t1.user_id = $url_user_id LIMIT 1"
Enable input field based on another input drop down field selection

Enable input field based on another input drop down field selection


By : nero
Date : March 29 2020, 07:55 AM
like below fixes the issue I am having a form as: , Add class to your main div of check boxes as:
code :
<div class="field user_checkbox_fields" style="display:none;">
$(document).ready(function(){
    $("#employee_role_id").click(function () {
        if($("#employee_role_id")[0].value=="User") {
            $(".user_checkbox_fields").css("display","block");           
        }
        else {
            $(".user_checkbox_fields").css("display","none");
        }
    });
Disable submit button when value in input field is already in database

Disable submit button when value in input field is already in database


By : Vheissa
Date : March 29 2020, 07:55 AM
Hope this helps I have input field where user can enter username. When user submit username it is inserted in mySQL database. If username is already in database ajax checks it and returns x and if it is not in database it return check icon. Problem is that I need to disable submit button when ajax returns x. , I added this to my js:
code :
if(username.length >= 1){
        $("#user-result").html('<img src="images/ajax-loader.gif" />');
        $.post('../check_username.php', {'username':username}, function(data) {
                       // console.log(data);
                        if (data == 'No' ){
                          $("#submit").prop('disabled', true);
          $('#user-result').html('<img src="images/not-available.png" />')

                    }else{
                       $("#submit").prop('disabled', false);
          $('#user-result').html('<img src="images/available.png" />')
                    }

        });
    }
  if($username_exist) {

echo'No';


}else{

            echo'Yes';
}
php setting value of drop down and radio button with data fetched from database

php setting value of drop down and radio button with data fetched from database


By : Qiqi
Date : March 29 2020, 07:55 AM
will help you Started coding in php few days back and am facing following issue. As the php page loads, am getting details from table and trying to set value of a drop down based on that value that I get from the table. , I think you are missing the ; after each echo.
It should be:
code :
<?php if(!is_null($user)){ if($user['fruit']=="apple"){echo '<option value="apple" selected="selected">Apple</option>';}}else{echo '<option value="apple">Apple</option>';}?>
<?php if(!is_null($user)){ if($user['grad_semister']=="banana"){echo '<option value="banana" selected="selected">Banana</option>';}}else{echo '<option value="banana">Banana</option>';}?>
Allow drag text and drop it in html input field without clearing previous data

Allow drag text and drop it in html input field without clearing previous data


By : pyopyopyo
Date : March 29 2020, 07:55 AM
I wish this helpful for you You cannot append data to an input field but you can take the old value and add to it. Get the value which is dragged by event.dataTransfer.getData('text'); and then add it with the old value like
code :
var input = document.getElementById("test");
input.addEventListener('drop', function (event) {
    event.preventDefault();
    var textData = event.dataTransfer.getData('text'); // get the dragged value
    var oldval = event.target.value; // get the old value in the input
    var newval = oldval + textData; // add it with the value which is dragged upon
    event.target.value = newval; // change the value with the new value
});
document.querySelector('[draggable="true"]').addEventListener('dragstart', function(e){
  e.dataTransfer.setData('text', e.target.innerHTML);
});
<input id="test">
<p draggable="true">Some text</p>
Related Posts Related Posts :
  • How to change add and remove active class in JavaScript
  • how to toggle a specific div in javascript
  • How to get all the values from multiple keys of an array of object?
  • jQuery bind() unbind() and on() and off()
  • regular expression to find DD Month YYYY from a string
  • How to upload files from web client (HTML/jQuery form) to your Dropbox folder
  • Backbone history and require.js issue
  • Confusion over Classical and Prototypal Inheritance Javascript
  • How to take screen shot of current webpage using Javascript/JQuery?
  • Store meridiem in a variable
  • class declared inside closure vs standard class without closure
  • javascript confirm box always return true
  • dynamically changing the size of font size based on text length using css and html
  • Node.js - Getting the host IP address while on Amazon EC2
  • Confusing CSS, can anyone explain please
  • How to install v8-profiler on Windows 8 (64 bit) using npm?
  • Resolve promise based on another promise
  • google maps adding overlay layer above UI and markers
  • Style specific letter?
  • RangeError: Maximum call stack size exceeded with array.slice
  • node rest client get with local variable
  • If condition not executes while mouse move fastly
  • Count the number of displayed elements in a HTML list
  • Locate JavaScript source code in Emacs
  • Clean, Modular Code vs MV* Frameworks
  • infinite scroll without loading image
  • Backbone: reverse collection order with comparator
  • What do printers ignore?
  • jQuery UI .tabs() Contentless tab?
  • Execute Javascript alert() after page (visually) loaded
  • JavaScript - duplicating array doesn't work
  • Excessive clickable area below image
  • JavaScript Regex: Replace |b| with <b>
  • Unexpected value change in 2D array in JavaScript
  • Function doesnt see parameter as a array of objects
  • jQuery fetch keypress event on chrome and IE
  • How to enable jquery validate localization?
  • Cassandra map collection returned by node.js Helenus looks odd
  • angular ng-repeat with multiple filter options
  • Selecting Children without ID or Class names
  • How to uncheck a group of checkboxes when another checkbox is checked
  • Is hiding content by Javascript or jQuery Worth trying
  • Load XUL resource using javascript
  • XML to HTML text area from server file system
  • set focus() on textbox on form onload
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • How to hide other div apart from touched div to the band
  • Is global variable assignment atomic on NodeJS?
  • Datepicker onchangemonthyear beforeshowday
  • trying to render html files using jade but it still adresses it as a jade
  • Google Analytics - Understanding and Dissecting the Snippet: What is | | [ ];
  • Replacing "[aA09.b]." to "[aA09.b]\n" in in JavaScript
  • Why wrap a function definition in an immediate function?
  • Enable / disable jQuery script on switching to different tab in a HTML page
  • how can find return variable value outside anonymous function in node js mysql query function
  • Converting 1 to 0001 in javascript array
  • svg viewbox should not resize the text fontSize?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org