Jump to content

Search the Community

Showing results for tags 'javascript'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 55 results

  1. Hi Not even sure if this is possible, but well here goes: We have a wholesale site where companies, organisations, clubs etc can buy products. We are setting it up so that these organisations can pick their items then our system will set up a webshop for them, they can then send the link to their employees, members to order the items that the company has chosen ahead of time. our site would be http://www.ourcompanyname.com/productpage.php?companyName=ourClient we would like if poss : http://www.ourcompanyname.com/ClientOrganisationName(either with or without the PHP extension). ClientOrganisationName would be taken from their record in mysql. If this is possible could someone please just tell me what i need to look up. I think wordpress has something similar which is prob where i thought about using on our site. thanks very much, MsKazza.
  2. I have two functions that execute an exe program (personal project for a minecraft back end.) Windows only. First one will execute the sending of commands (THIS ONE WORKS) /* check to see if admin is sending commands to terminal via web */ if(isset($_POST['command'])) { $content = $_POST['command']; writeMCCommandTxt($content); try { exec(SERVER_DIR.'mcCommand.exe',$output); } catch ( Exception $e ) { die ($e->getMessage()); } }// END COMMAND ENTRY This has been a head scratcher for most the week - any help or suggestions would be great!! thanks!! HTML <div id="commands"> <div id="command_input"> <form method="post" id="commandForm" action="index.php"> <label for="command" >Console Command:</label><br/> <input type="text" name="command" autofocuS/> <input type="submit" name="submit_command" value=" >> " /> &nbsp; <input type="button" value="Refresh page" onclick="location.reload(true);" /> </form> </div> </div> This is used to start the server // STARTING SERVER if(isset($_POST['startServerBtn'])){ try { exec(SERVER_DIR.'startServer.bat 2>&1' ,$output); } catch( Exception $e ) { die ($e->getMessage()); } } HTML <div id="server_control"> <ul> <li> <form action="index.php" method="post"> <input type="submit" value="START" id="startServerBtn" name="startServerBtn"/> </form> </li> </ul> </div> MCCOMMANDS.EXE will work from both browser(php) and file manager(tested) the STARTSERVER.EXE will NOT work from browser(php), but will work from file manager The function IS being accessed - debug is showing it going there, and it seems to be running Both exe's are in the same folder
  3. Hi Guys, I have created a calendar view with this plug in. http://fullcalendar.io/ The calendar view will show calendar view by Start Date and End Date. So I have some problem with some of the event, the start date is from 01-January-2015 until 15-Jan-2015, but in between actually there is a break. For example, 01-January-2015 until 03-January-2015 13-January-2015 until 15-January-2015 So, because of the start date and the end date is so long, so in the calendar view, it block the calendar from 01/Jan until 15/Jan. Its look weird. Actually i have actual dates column in my database column in this format: 01-01-2015,02-01-2015,03-01-2015,13-01-2015,14-01-2015,15-01-2015Start Date column 01-01-2015 End Date column 15-01-2015So, i was wondering is there any script to detect each of date to separate the break in between the start date and end date. Thank You
  4. <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <div id="txtHint"></div> <script> function showUser(str) { // alert (str); if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "new.php?q=" + str, true); xmlhttp.send(); } } </script> <body> <form> <select onchange="showUser(this.value)"> <option value="1" > 1 </option> <option value="3" > 3 </option> </select> <?php $con = mysqli_connect("localhost", "root", ""); mysqli_select_db($con, "crud_tutorial"); if (isset($_REQUEST['q'])) { $q = intval($_GET['q']); //echo "$q"; $sql = "SELECT * FROM customers WHERE id = '" . $q . "'"; $result = mysqli_query($con, $sql); } else { $sql = "SELECT * FROM customers "; $result = mysqli_query($con, $sql); } echo "<table> <tr> <th>id</th> <th>name</th> </tr>"; while ($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> </form> </body> </html>
  5. Hi Mate, I need help on using the jquery clone method. i have this html script that i clone <div class="col-md-2 col-sm-3 col-lg-1 nopadding"> <input id="length" class="form-control input-sm nopadding" type="text" onchange="compute('floor','length','width','sqft');" placeholder="Length" maxlength="4" name="length"> </div> Then when i cloned, it outputs this with id appending an incremented number at the end of the original id. example (length to length1) which is correct. <div class="col-md-2 col-sm-3 col-lg-1 nopadding"><input id="length1" class="form-control input-sm nopadding" type="text" onchange="compute('floor','length','width','sqft');" placeholder="Length" maxlength="4" name="length"> </div> Now how can i pass the same ids to the onchange event so it should output compute('floor1','length1','width1','sqft1'). at the moment it did not pass the incremented id to the method. here is my javascript: function addrow(){ var template = $('#rowsec').clone(); rCount++; var attendee = template.clone().find(':input').val(0).each(function(){ var newId = this.id.substring(0, this.id.length) + rCount; this.id = newId; }).end() .attr('id', 'rowsec' + rCount) .appendTo('#rows'); } Thank you in advance.
  6. Hello, Im hoping to get help from here, i have arrays of text fields that i need to get sums,.. <div class='fldgroup'> <input type="text" name="fld[0]"> <input type="text" name="fld[0]"> <input type="text" name="fld[0]"> <input type="text" name="sumfld[0]"> <button>Add Another Field</button> <input type="text" name="fld[1]"> <input type="text" name="fld[1]"> <input type="text" name="fld[1]"> <input type="text" name="sumfld[1]"> <button>Add Another Field</button> </div> <button>Add Another Group</button> how can i get the sum of all fld[0] and put it to sumfld[0] same as the fld[1] to sumfld[1],.. every text field is dynamically added using clone., i hope somebody can help me with this.... Thank you in advance...
  7. So I have a code that is suppose to save form sessions and then redirect to another website. It does redirect but the sessions are never saved when I go back to my site. And yes, I do have session_start() at the very top of the page. And also, the sessions do get saved on locahost server but not live server. Do you know why this is happening? Here's the code example. if(isset($_POST['submit'])) { $name = trim($_POST['name']); $email = trim($_POST['email']); $_SESSION['name'] = $name; $_SESSION['email'] = $email; $errors = array(); $db->beginTransaction(); if(empty($name)) { $errors[] = 'Name is required.'; } if(empty($email)) { $errors[] = 'Email is required.'; } if(empty($errors)) { $db->commit(); $new_url = 'https://www.google.ca/'; ?> <script> window.location.href = '<?php echo $new_url; ?>'; </script> <?php exit(); } else { $db->rollBack(); } }
  8. Hello, I need help in using split with utf8 string like below: <!DOCTYPE html><html><body><script>var numbers;var Emoj1 = '
  9. I want the modal to show after the user has fill the form, But don't know how to do that. Am very new in javascript. After the user have fill the form and click on the proceed button the modal should pop up but if the user did not fill all the form the modal should not display and and an error message should alert.. When the modal display then the user should fill the 1st modal form with a code 123456, if the user did not put anything or give a wrong code the 2nd modal should not show but if he/she does it should display. THIS IS THE HTML FORM <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"> <div align="center"> <p> Funds Transfer </h3> </div> <div class="panel-body"> <div align="center"> <p> Bank of lgbt Funds Transfer Service makes it easy to transfer funds to other beneficiaries within the bank or to other domestic bank.<br> To effect transfer of funds, please complete and submit the form below. Please note that all account numbers are required to be NUBAN compliant. </br> <div id="middle"> <table class=""> <tr> <th> <label for="funds transfr" >*Funds Transfer Type: </label> </th> <td><p> <select name="fundstransfr" maxlength="20" tabindex="108" > <option value=" "> </option> <option value="Internal">Internal</option> <option value="External">External</option> </select> </p> <p> </p> </td> <tr> <th> <label for= "transfr from" >*Transfer from: </label> </th> <td><p> <select name="transfrfrom" maxlength="20" tabindex="108"> <option value=" "> </option> <option value="Premier Account">Premier Account</option> <option value="Credit Card">Credit Card</option> </select> </p> <p> </p> </td> <td> </td> <td> </td> <tr> <th> <label for="amount">*Amount:</label> </th> <td> <p> <input type="number" name="amount" value="" placeholder="0.00" maxlength="30" size="12" tabindex="106"> </p> <p> </p></td> <td> </td> <td> </td> <tr> <th> <label for="Beneficiary Name">*Beneficiary Name:</label> </th> <td> <input type="text" name="BeneficiaryName" value="" maxlength="40" size ="30"tabindex="107"></td> <td><p> </p> <p> </p></td> <td> </td> <td colspan="2"> </td> </tr> <tr> <th> <label for="Beneficiary Bank" >*Beneficiary Bank:</label></th> <td><p> <select name="BeneficiaryBank" maxlength="20" tabindex="108"> <option value=""> </option> <option value="">Bank of trump</option> <option value="">Obama bank</option> </select> </p> <p> </p></td> <td> </td> <td> </td> <td colspan="2"> </td> </tr> <tr> <th><label for="Beneficiary Accountr" >*Beneficiary Account No (NUBAN):</label></th> <td><p> <input type="number" name="BeneficiaryAccount" value="" placeholder="N/A" maxlength="20" tabindex="116" maxlength="20" tabindex="114"/> </p> <p> </p></td></form> <tr> <th> <label for="Payment Reference" class="btn-group-lg"> Payment Reference:</label> </th> <td><input type="text" name="PaymentReference" value=""></td><br> </table> ><br> <!-- Trigger/Open The Modal --> <button type="button" id="myBtn" class="btn btn-info" data-toggle="modal" data-target="#myModal" >Proceed</button> THIS IS THE MODAL WINDOW <!-- The Modal --> <div id="myModal" class="modal"> <!-- Modal content --> <div class="modal-content"> <div class="modal-header"> <spal class="close1">×</spal> <h4 class="modal-title">Please enter your secure Transaction Code.</h4> </div> <div class="modal-body"> <label for="TransactionCode">*Transaction Code:</label> <input type="text" name="TransactionCode" value="" maxlength="40" size ="30"tabindex="107"> <p> For Transaction Code <a href="#">click here</a></p> </div> <div class="modal-footer"> <button type="button" id ="myBtn2"class="btn btn-info" data-toggle="modal" data-target="#myModal2">Proceed</button> </div> <!-- The Modal --> <div id="myModal2" class="modal"> <!-- Modal content --> <div class="modal-content"> <div class="modal-header"> <span class="close2">×</span> <h4 class="modal-title">Please enter your secure Tax verification code.</h4> </div> <div class="modal-body"> <label for="taxcode">*Tax Verification Code:</label> <input type="text" name="taxcode" value="" maxlength="40" size ="30"tabindex="107"> <p> For Tax Verification Code <a href="#">click here</a></p> </div> <div class="modal-footer"> <button type="button" id ="myBtn2"class="btn btn-info" data-toggle="modal" data-target="#myModal2">Proceed</button> </div> </div> </div> </div> </div> </div> THIS IS THE SCRIPT <script> // Get the modal var modal = document.getElementById('myModal'); var modal2 = document.getElementById('myModal2'); // Get the button that opens the modal var btn = document.getElementById("myBtn"); var btn2 = document.getElementById("myBtn2"); // Get the <span> element that closes the modal var spal = document.getElementsByClassName("close1")[0]; var span = document.getElementsByClassName("close2")[0]; // When the user clicks the button, open the modal btn.onclick = function() { modal.style.display = "block"; } // When the user clicks the button, open the modal btn2.onclick = function() { modal2.style.display = "block"; } // When the user clicks on <span> (x), close the modal spal.onclick = function() { modal.style.display = "none"; } // When the user clicks on <span> (x), close the modal span.onclick = function() { modal2.style.display = "none"; } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "block"; } } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal2) { modal2.style.display = "block"; } } </script>
  10. Hey guys, i am trying to create a box to show images or content once a user selects a link within a gallery. So for example i have an image --> user scrolls over --> image overlay shows a link ---> link actions to a jquery action to where a hidden field shows more data. right now i have everything to the point to where the links default action is disabled and the "overlay" div that will show the content is hidden. when i then go ahead and add some jquery to add a class when the link is clicked nothing seems to happen. <section class="work_area" id="WORK"> <div class="container"> <div class="row"> <div class="col-md-12 text-center"> <div class="work_title wow fadeInUp animated"> <h1>demo<span style="color: #64bdec; font-weight: bolder;">33</span> PORTFOLIO</h1> <img src="images/arrow486.png" alt=""> </div> <div id="dataBox"></div> </div> </div> </div> <div class="container-fluid"> <div class="row"> <div class="col-md-2 no_padding"> <div class="single_image"> <img src="images/REGISTERE.png" alt=""> <div class="image_overlay"> <h2>Lorem ipsum</h4> <a id="link" href="portfolio.php" >Popup link</a> </div> </div> </div> </div> </div> </section> CSS #dataBox{ width: 800px; height: 500px; margin: auto; padding: 100px 100px; position: relative; border: 2px solid black; margin-bottom: 10px; } #pData{ background: red; width: 800px; height: 500px; margin: auto; padding: 100px 100px; position: relative; border: 2px solid black; } JS. $(document).ready(function(){ $('#dataBox').hide(); $('#link').click(function(e){ e.preventDefault(); $('div #dataBox').removeClass().addClass('pData'); console.log("link is working"); }); }); everything works other than the div showing up.
  11. I have just begun dabbling with javascript as a hobby and have a very crude understanding of php so please bare with me, I am a noob! I am using a javascript onclick button to reference the function shown below. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { }); location.reload(); } When the button is pressed and the function executes it does as it should. It deletes the forum reply post as its told and the page reloads and the post is gone! But without some sort of explanation, success message or something telling me that it did what its intended is very unsatisfying. I read around and found that an additional function is needed to give me a little message. success : function() { var x="Success"; alert(x); } Looks simple enough and one would think should be easy to incorporate but when I add it in every way shape or form I cannot get it to work. The original function wont even work after adding this. Below is basically what I am wanting to do but not quite sure how to go about it. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { }); success : function() { var x="<?php $mtg->success("Reply has been deleted."); ?>"; alert(x); location.reload(); } } I want to use the php $mtg->success() function to echo the message in the pre defined output location and format and want to output the message after the reload... Any ideas on how to go about this?
  12. Hi guys. I have a Bootstrap modal that opens on click. Inside is a form with 4 fields. Now i want after the form is submited to show below the submit button a thank yo message, but instead of that the form closes and the page is beeing refreshed. I've manage to do some javascript to stop the form of beeing refreshed but now i want to know how can i make the thank you div to get showed below the submit button. <script> $(function () { var frm = $('#participa-modal'); frm.submit(function (ev) { $.ajax({ type: frm.attr('method'), url: frm.attr('action'), data: frm.serialize(), success: function (data) { $(".alert-success").html(data); location.reload(); } }); ev.preventDefault(); }); }); </script>
  13. hello if there is just the first function it run very good but if I add the second I get the message in Firefox " TypeError: event.target is undefined " (function(){ document.getElementById("ta").onclick = function(){ ta(); }; function ta(){ var tav = document.getElementById("ta").value, ta = document.getElementById("ta"); ta.setAttribute('style','height:200px;') } })(); window.onclick = function(event) { var tav = document.getElementById("ta").value, ta = document.getElementById("ta"); if (! event.target.matches('#ta')) { if( tav == "" ){ ta.setAttribute('style','height:25px;'); } else if( tav !== "" ){ ta.setAttribute('style','height:200px;'); } } } (function(){ document.getElementById("close").onclick = function(){hide_notify();}; function hide_notify(){ var notify = document.getElementById("notify"); notify.parentElement.removeChild(notify); } })(); I'm still new in JavaScript so I have no idea what is going on ! thanks.
  14. I am new to Javascript, so please forgive me if this is a dumb question See attached screen shot. My JS code computes the value of "cost" and it sets it into the input of a a form using row.val(cost). When it has calculated all the costs for all the products, adding, subtracting and multiplying, I want to find the total. So, I now scan through all the cost inputs using an "each" method and create a sum total. Problem: the calculated cost inputs are visible on the screen. If a user changes their mind about the quantity required on a particular line item, the grand total must be recalculated. However the line totals are calculated. Therefore, they do not appear in the source code, so, I can not grab them using the selector $("input.cost") Question: How do I grab the values of the computed cost values which are visible in the input fields? row.data('price') // THIS IS DECLARED IN AN EARLIER FUNCTION. var runningTotal = 0; // THIS IS DECLARED AS A GLOBAL $("input.quantity").on('change', function() { var row = $(this).parents(':eq(1)').find('input').filter(".cost"); var price = row.data('price'); if (price) { var quantity = parseFloat($(this).val()); var cost = (price * quantity); row.val(cost); // COST INSERTED HERE!! $("input.cost").each(function(){ var ic = $(this).val(); // TRIED USING HTML AND TEXT METHODS. var inputCost = Number(ic); runningTotal += inputCost; }); $("#total").val(runningTotal); } HTML for a typical row: ( I am using Laravel Blade, however this is the rendered HTML) <div class="well form-group "> <div class="col-sm-2 col-md-2"><label for="underlay2">Underlayments:</label></div> <div class="col-sm-4 col-md-4"><select class="form-control product_id" name="product_code[4]"><option selected="selected" value="">None</option><option value="789">BP #15 Plain Felt 36" | $10.00</option><option value="790">BP #30 Plain Felt 36" | $10.00</option></select></div> <div class="col-sm-1 col-md-1"><label for="underlay2_req">Quantity:</label></div> <div class="col-sm-2 col-md-2"><input class="form-control quantity" name="quantity[4]" type="text"></div> <div class="col-sm-1 col-md-1"><label for="cost">Cost:</label></div> <div class="col-sm-2 col-md-2"><input class="form-control cost" readonly="readonly" name="cost[0]" type="text" value=""></div> </div>
  15. Hi all, The following code was working fine up until 1 hour ago and now fails to execute the PHP function call or anything within isset($_POST ​The JavaScript works successfully but I had to change the order in which form onsubmit and form action were called. As I said, I was getting the echo message back from the function until 1 hour ago. Here is the code. At the start of my page with the form: <?php session_start(); require_once 'class.user.php'; $user_home = new USER(); if(!$user_home->is_logged_in()) { $user_home->redirect('signin.php'); } $stmt = $user_home->runQuery("SELECT * FROM user WHERE id=:uid"); $stmt->execute(array(":uid"=>$_SESSION['userSession'])); $row = $stmt->fetch(PDO::FETCH_ASSOC); // print_r($row['learner_type']); ?> The code to check if the submit button has been clicked <?php if(isset($_POST['save_profile_changes'])) { $user_home->save_user_profile(); ?> <div class='alert alert-success alert-dismissible'> <button class='close' data-dismiss='alert'>×</button> <strong>Profile Submitted Successfully</strong> </div> <?php } else { //Left blank so it doesn't fire on form first load } ?> and the form code <form id="user_profile" name="user_profile" class="form-signin" onsubmit="return validateUserInput()" method="post" action="#"> <h2 class="form-signin-heading">Update Profile</h2> <!--Username, Email. Unchangeable for now--> <div> <strong> <label><strong>Username: </strong></label> <?php echo $row['username']; ?> <br> <label><strong>Email: </strong></label> <?php echo $row['email']; ?> </strong> <br> <a href="change_pass.php" style="padding-top:10px; font-weight: bolder">Change Password</a> <br><br> </div> <!-- First, Last Name --> <div> <input id="first_name" name="first_name" type="text" placeholder="First Name" class="form-control" minlength="2" maxlength="15" pattern="[A-Za-z]{2,15}" title="Only letters allowed" required> <input id="last_name" name="last_name" type="text" placeholder="Last Name" class="form-control" minlength="2" maxlength="25" pattern="[A-Za-z]{2,25}" title="Only letters allowed" required> </div> <!-- File Button --> <div> <label for="upload_photo">Upload Photo</label> <input class = "form-control" id="upload_photo" name="upload_photo" type="file" accept="image/*"> </div> <!-- DOB input--> <br> <div> <label for="dob">Date of Birth</label> <input id="dob" name="dob" type="date" class="form-control" min="1935-12-31" max="2014-12-31"required> </div> <!-- Gender --> <br> <div> <label for="Gender">Gender</label><br> <label class="radio-inline" for="gender-0"> <input type="radio" name="gender" id="gender-0" value="male" required> Male </label> <label class="radio-inline" for="gender-1"> <input type="radio" name="gender" id="gender-1" value="female"> Female </label> <label class="radio-inline" for="gender-2"> <input type="radio" name="gender" id="gender-2" value="other"> Other </label> </div> <!-- Region --> <br> <div> <label for="country">Select Your Country</label> <script type="text/javascript" src="assets/countries.js"></script> <select id="country" name="country" class="form-control" required></select> <script language="javascript"> populateCountries("country"); </script> </div> <!-- Occupation--> <br> <div> <label for="occupations">Select Your Occupation</label> <script type="text/javascript" src="assets/occupations.js"></script> <select id="occupations" name="occupations" class="form-control" required></select> <script language="javascript"> populateOccupations("occupations"); </script> </div> <!-- Primary Instructor Language --> <br> <div> <label for="languages">Primary Language of Instruction</label> <script type="text/javascript" src="assets/languages.js"></script> <select id="languages" name="languages" class="form-control" required></select> <script language="javascript"> populateLanguages("languages"); </script> </div> <!-- Bio --> <br> <div> <label for="bio">Bio (max 200 words)</label> <textarea class="form-control" rows="10" id="bio" name="bio" placeholder="Say a little about yourself." maxlength="200"> </textarea> </div> <!--Submission Buttons--> <hr> <div> <button class="btn btn-primary btn-common font18" type="submit" name="save_profile_changes">Save Changes</button> <a href="home.php" style="float:right; padding-top:10px;">Go Back Home</a> </div> </form> Thanks for any help you can provide.
  16. <script type="text/javascript" language="javascript"> function disableFunc() { document.getElementById("groupselect").disabled = true; } </script> <form method="post" class="subform" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>"> <div class="row" style="background: skyblue; margin-top:-23px"> <div class="col-sm-2"> <div class="input-group"> <select id="groupselect" class="form-control" name="groupid" onchange="disableFunc()"> <option name="0"<?php echo ($_POST['groupid'] == '0') ? ' selected="selected"' : ''; ?> value="0" >GROUP</option> <option name="1"<?php echo ($_POST['groupid'] == '1') ? ' selected="selected"' : ''; ?> value="1" >1</option> <option name="2"<?php echo ($_POST['groupid'] == '2') ? ' selected="selected"' : ''; ?> value="2" >2</option> <option name="3"<?php echo ($_POST['groupid'] == '3') ? ' selected="selected"' : ''; ?> value="3" >3</option> <option name="4"<?php echo ($_POST['groupid'] == '4') ? ' selected="selected"' : ''; ?> value="4" >4</option> <option name="5"<?php echo ($_POST['groupid'] == '5') ? ' selected="selected"' : ''; ?> value="5" >5</option> <option name="6"<?php echo ($_POST['groupid'] == '6') ? ' selected="selected"' : ''; ?> value="6" >6</option> The onchange function works as it shld. My problem is the HTML. I got this select box code from another forum. Without the onchange event in the code, when the user selects a Groupid option, it automatically loads another select box with names. But with it in the code (as I've shown it here), the select box gets disabled immediately causing no names to be loaded in the other select box. I need to be able to load the other select box with names before the groupid select box disables. Any help on this is appreciated. Thanks.
  17. Edit: upload blob not blog I would like to use the following code to crop images that will be uploaded to mySql with PHP. I just cannot figure out how to call the blob so I can use it. Can someone help me with this? Using the code from here: http://hongkhanh.github.io/cropbox/ HTML <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Crop Box</title> <link rel="stylesheet" href="style.css" type="text/css" /> <style> .container { position: absolute; top: 10%; left: 10%; right: 0; bottom: 0; } .action { width: 400px; height: 30px; margin: 10px 0; } .cropped>img { margin-right: 10px; border:1px solid green: } </style> </head> <body> <script src="../cropbox.js"></script> <div class="container"> <div class="imageBox"> <div class="thumbBox"></div> <div class="spinner" style="display: none">Loading...</div> </div> <div class="action"> <input type="file" id="file" style="float:left; width: 250px"> <input type="button" id="btnCrop" value="Crop" style="float: right"> <input type="button" id="btnZoomIn" value="+" style="float: right"> <input type="button" id="btnZoomOut" value="-" style="float: right"> </div> <div class="cropped"></div> <script type="text/javascript"> window.onload = function() { var options = { imageBox: '.imageBox', thumbBox: '.thumbBox', spinner: '.spinner', imgSrc: 'avatar.png' } var cropper = new cropbox(options); document.querySelector('#file').addEventListener('change', function(){ var reader = new FileReader(); reader.onload = function(e) { options.imgSrc = e.target.result; cropper = new cropbox(options); } reader.readAsDataURL(this.files[0]); this.files = []; }) document.querySelector('#btnCrop').addEventListener('click', function(){ var img = cropper.getDataURL(); document.querySelector('.cropped').innerHTML += '<img src="'+img+'">'; }) document.querySelector('#btnZoomIn').addEventListener('click', function(){ cropper.zoomIn(); }) document.querySelector('#btnZoomOut').addEventListener('click', function(){ cropper.zoomOut(); }) }; </script> </body> </html> /** * Created by ezgoing on 14/9/2014. */ 'use strict'; var cropbox = function(options){ var el = document.querySelector(options.imageBox), obj = { state : {}, ratio : 1, options : options, imageBox : el, thumbBox : el.querySelector(options.thumbBox), spinner : el.querySelector(options.spinner), image : new Image(), getDataURL: function () { var width = this.thumbBox.clientWidth, height = this.thumbBox.clientHeight, canvas = document.createElement("canvas"), dim = el.style.backgroundPosition.split(' '), size = el.style.backgroundSize.split(' '), dx = parseInt(dim[0]) - el.clientWidth/2 + width/2, dy = parseInt(dim[1]) - el.clientHeight/2 + height/2, dw = parseInt(size[0]), dh = parseInt(size[1]), sh = parseInt(this.image.height), sw = parseInt(this.image.width); canvas.width = width; canvas.height = height; var context = canvas.getContext("2d"); context.drawImage(this.image, 0, 0, sw, sh, dx, dy, dw, dh); var imageData = canvas.toDataURL('image/png'); return imageData; }, getBlob: function() { var imageData = this.getDataURL(); var b64 = imageData.replace('data:image/png;base64,',''); var binary = atob(b64); var array = []; for (var i = 0; i < binary.length; i++) { array.push(binary.charCodeAt(i)); } return new Blob([new Uint8Array(array)], {type: 'image/png'}); }, zoomIn: function () { this.ratio*=1.1; setBackground(); }, zoomOut: function () { this.ratio*=0.9; setBackground(); } }, attachEvent = function(node, event, cb) { if (node.attachEvent) node.attachEvent('on'+event, cb); else if (node.addEventListener) node.addEventListener(event, cb); }, detachEvent = function(node, event, cb) { if(node.detachEvent) { node.detachEvent('on'+event, cb); } else if(node.removeEventListener) { node.removeEventListener(event, render); } }, stopEvent = function (e) { if(window.event) e.cancelBubble = true; else e.stopImmediatePropagation(); }, setBackground = function() { var w = parseInt(obj.image.width)*obj.ratio; var h = parseInt(obj.image.height)*obj.ratio; var pw = (el.clientWidth - w) / 2; var ph = (el.clientHeight - h) / 2; el.setAttribute('style', 'background-image: url(' + obj.image.src + '); ' + 'background-size: ' + w +'px ' + h + 'px; ' + 'background-position: ' + pw + 'px ' + ph + 'px; ' + 'background-repeat: no-repeat'); }, imgMouseDown = function(e) { stopEvent(e); obj.state.dragable = true; obj.state.mouseX = e.clientX; obj.state.mouseY = e.clientY; }, imgMouseMove = function(e) { stopEvent(e); if (obj.state.dragable) { var x = e.clientX - obj.state.mouseX; var y = e.clientY - obj.state.mouseY; var bg = el.style.backgroundPosition.split(' '); var bgX = x + parseInt(bg[0]); var bgY = y + parseInt(bg[1]); el.style.backgroundPosition = bgX +'px ' + bgY + 'px'; obj.state.mouseX = e.clientX; obj.state.mouseY = e.clientY; } }, imgMouseUp = function(e) { stopEvent(e); obj.state.dragable = false; }, zoomImage = function(e) { var evt=window.event || e; var delta=evt.detail? evt.detail*(-120) : evt.wheelDelta; delta > -120 ? obj.ratio*=1.1 : obj.ratio*=0.9; setBackground(); } obj.spinner.style.display = 'block'; obj.image.onload = function() { obj.spinner.style.display = 'none'; setBackground(); attachEvent(el, 'mousedown', imgMouseDown); attachEvent(el, 'mousemove', imgMouseMove); attachEvent(document.body, 'mouseup', imgMouseUp); var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel'; attachEvent(el, mousewheel, zoomImage); }; obj.image.src = options.imgSrc; attachEvent(el, 'DOMNodeRemoved', function(){detachEvent(document.body, 'DOMNodeRemoved', imgMouseUp)}); return obj; };
  18. Hi guys, i have a table with 6 COLS and 12 ROWS. In the first column is a filed with dimensions (4 ml) and in the other 5 columns are the prices with are different one from another. What i like to do is when i click on a cell from the table to autocomplete bellow 2 inputs 1 with dimension and another with the price from that cell. I've manage to do the first part but the secound one i don't know how to do. Please have a look at my code below. (function () { if (window.addEventListener) { window.addEventListener('load', run, false); } else if (window.attachEvent) { window.attachEvent('onclick', run); } function run() { var t = document.getElementById('myTable'); t.onclick = function (event) { event = event || window.event; //IE8 var target = event.target || event.srcElement; while (target && target.nodeName != 'TR') { // find TR target = target.parentElement; } //if (!target) { return; } //tr should be always found //var cells = target.cells; //cell collection - https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement var cells = target.getElementsByTagName('td'); //alternative var f1 = document.getElementById('Inaltime / Dimensiune'); var f2 = document.getElementById('Ø 14'); var f3 = document.getElementById('Ø 16'); var f4 = document.getElementById('Ø 18'); var f5 = document.getElementById('Ø 20'); var f6 = document.getElementById('Ø 25'); f1.value = cells[0].innerHTML; f2.value = cells[1].innerHTML; f3.value = cells[2].innerHTML; f4.value = cells[3].innerHTML; f5.value = cells[4].innerHTML; f6.value = cells[5].innerHTML; //console.log(target.nodeName, event); }; } })(); <table id="myTable" class="demo"> <caption> <h3>Sisteme de cosuri fum TONA <span class="orange-price">- 15% REDUCERE</span></h3></caption> <thead> <tr> <th> Inaltime / Dimensiune </th> <th>Ø 14</th> <th>Ø 16</th> <th>Ø 18</th> <th>Ø 20</th> <th>Ø 25</th> </tr> </thead> <tbody> <tr> <td>5 ml <br> </td> <td><span class="old-price">583 EUR</span> <br> <span class="orange-price">496 EUR</span> </td> <td><span class="old-price">630 EUR</span> <br> <span class="orange-price">536 EUR</span> </td> <td><span class="old-price">661 EUR</span> <br> <span class="orange-price">562 EUR</span> </td> <td><span class="old-price">704 EUR</span> <br> <span class="orange-price">598 EUR</span> </td> <td><span class="old-price">1125 EUR</span> <br> <span class="orange-price">956 EUR</span> </td> </tr> <tr> <td>5.5 ml</td> <td><span class="old-price">608 EUR</span> <br> <span class="orange-price">517 EUR</span> </td> <td><span class="old-price">659 EUR</span> <br> <span class="orange-price">560 EUR</span> </td> <td><span class="old-price">692 EUR</span> <br> <span class="orange-price">588 EUR</span> </td> <td><span class="old-price">737 EUR</span> <br> <span class="orange-price">626 EUR</span> </td> <td><span class="old-price">1187 EUR</span> <br> <span class="orange-price">1009 EUR</span> </td> </tr> <tr> <td>6 ml</td> <td><span class="old-price">634 EUR</span> <br> <span class="orange-price">539 EUR</span> </td> <td><span class="old-price">687 EUR</span> <br> <span class="orange-price">584 EUR</span> </td> <td><span class="old-price">722 EUR</span> <br> <span class="orange-price">614 EUR</span> </td> <td><span class="old-price">770 EUR</span> <br> <span class="orange-price">655 EUR</span> </td> <td><span class="old-price">1250 EUR</span> <br> <span class="orange-price">1063 EUR</span> </td> </tr> <tr> <td>6.5 ml</td> <td><span class="old-price">659 EUR</span> <br> <span class="orange-price">560 EUR</span> </td> <td><span class="old-price">716 EUR</span> <br> <span class="orange-price">609 EUR</span> </td> <td><span class="old-price">752 EUR</span> <br> <span class="orange-price">639 EUR</span> </td> <td><span class="old-price">803 EUR</span> <br> <span class="orange-price">683 EUR</span> </td> <td><span class="old-price">1313 EUR</span> <br> <span class="orange-price">1117 EUR</span> </td> </tr> <tr> <td>7 ml</td> <td><span class="old-price">685 EUR</span> <br> <span class="orange-price">582 EUR</span> </td> <td><span class="old-price">745 EUR</span> <br> <span class="orange-price">633 EUR</span> </td> <td><span class="old-price">782 EUR</span> <br> <span class="orange-price">665 EUR</span> </td> <td><span class="old-price">836 EUR</span> <br> <span class="orange-price">711 EUR</span> </td> <td><span class="old-price">1375 EUR</span> <br> <span class="orange-price">1169 EUR</span> </td> </tr> <tr> <td>7.5 ml</td> <td><span class="old-price">710 EUR</span> <br> <span class="orange-price">604 EUR</span> </td> <td><span class="old-price">774 EUR</span> <br> <span class="orange-price">660 EUR</span> </td> <td><span class="old-price">812 EUR</span> <br> <span class="orange-price">690 EUR</span> </td> <td><span class="old-price">869 EUR</span> <br> <span class="orange-price">739 EUR</span> </td> <td><span class="old-price">1438 EUR</span> <br> <span class="orange-price">1222 EUR</span> </td> </tr> <tr> <td>8 ml</td> <td><span class="old-price">735 EUR</span> <br> <span class="orange-price">625 EUR</span> </td> <td><span class="old-price">803 EUR</span> <br> <span class="orange-price">683 EUR</span> </td> <td><span class="old-price">843 EUR</span> <br> <span class="orange-price">717 EUR</span> </td> <td><span class="old-price">902 EUR</span> <br> <span class="orange-price">767 EUR</span> </td> <td><span class="old-price">1500 EUR</span> <br> <span class="orange-price">1275 EUR</span> </td> </tr> <tr> <td>8.5 ml</td> <td><span class="old-price">761 EUR</span> <br> <span class="orange-price">647 EUR</span> </td> <td><span class="old-price">831 EUR</span> <br> <span class="orange-price">706 EUR</span> </td> <td><span class="old-price">873 EUR</span> <br> <span class="orange-price">742 EUR</span> </td> <td><span class="old-price">935 EUR</span> <br> <span class="orange-price">795 EUR</span> </td> <td><span class="old-price">1563 EUR</span> <br> <span class="orange-price">1329 EUR</span> </td> </tr> <tr> <td>9 ml</td> <td><span class="old-price">802 EUR</span> <br> <span class="orange-price">682 EUR</span> </td> <td><span class="old-price">876 EUR</span> <br> <span class="orange-price">745 EUR</span> </td> <td><span class="old-price">919 EUR</span> <br> <span class="orange-price">781 EUR</span> </td> <td><span class="old-price">984 EUR</span> <br> <span class="orange-price">836 EUR</span> </td> <td><span class="old-price">1642 EUR</span> <br> <span class="orange-price">1396 EUR</span> </td> </tr> <tr> <td>9.5 ml</td> <td><span class="old-price">827 EUR</span> <br> <span class="orange-price">703 EUR</span> </td> <td><span class="old-price">905 EUR</span> <br> <span class="orange-price">769 EUR</span> </td> <td><span class="old-price">949 EUR</span> <br> <span class="orange-price">807 EUR</span> </td> <td><span class="old-price">1017 EUR</span> <br> <span class="orange-price">864 EUR</span> </td> <td><span class="old-price">1704 EUR</span> <br> <span class="orange-price">1448 EUR</span> </td> </tr> <tr> <td>10 ml</td> <td><span class="old-price">853 EUR</span> <br> <span class="orange-price">725 EUR</span> </td> <td><span class="old-price">934 EUR</span> <br> <span class="orange-price">794 EUR</span> </td> <td><span class="old-price">979 EUR</span> <br> <span class="orange-price">832 EUR</span> </td> <td><span class="old-price">1050 EUR</span> <br> <span class="orange-price">893 EUR</span> </td> <td><span class="old-price">1767 EUR</span> <br> <span class="orange-price">1502 EUR</span> </td> </tr> <tbody> </table>
  19. I have made an ajax call (using file activedirectory.php) to active directory to retrieve information such as name,thumbnail photo,mail etc. the ajax call is made on click of a name in a leaderboard ,to fetch only that person's info by matching the post['id']. The problem is that I am unable to retrieve any information and the console gives me an error saying : SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data the error type makes it clear that it is unable to pull any data whatsoever. .php file that has been used here :(activedirectory.php) -- <?php /** * Get a list of users from Active Directory. */ $ad_users = ''; $message = ''; $ldap_password = 'Qwerty@33xxxxxx'; $ldap_username = 'maxxxxxxxxxxxx'; $server = 'ldap://xxxxxxxxxx'; $domain = '@asia.xxxxxx.com'; $port = 389; $ldap_connection = ldap_connect($server, $port); if (FALSE === $ldap_connection){ // Uh-oh, something is wrong... } // We have to set this option for the version of Active Directory we are using. ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version'); ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0); // We need this for doing an LDAP search. if (TRUE === ldap_bind($ldap_connection, $ldap_username.$domain, $ldap_password)){ $base_dn = "OU=Employees,OU=Accounts,OU=xxxxx,DC=xxxxx,DC=xxxxxx,DC=com"; $kid = 'NonExistingAccount'; if (preg_match('#SAM_NAME_MATCHING_REGEX#', $_POST['id'])) { $kid = $_POST['id']; } $search_filter = "(&(objectCategory=person)(samaccountname={$kid}))"; $attributes = array(); $attributes[] = 'givenname'; $attributes[] = 'mail'; $attributes[] = 'samaccountname'; $attributes[] = 'sn'; $result = ldap_search($ldap_connection, $base_dn, $search_filter, $attributes); $maxPageSize = 1000; if (FALSE !== $result){ $entries = ldap_get_entries($ldap_connection, $result); for ($x=0; $x<$entries['count']; $x++){ if (!empty($entries[$x]['givenname'][0]) && !empty($entries[$x]['mail'][0]) && !empty($entries[$x]['samaccountname'][0]) && !empty($entries[$x]['sn'][0]) && 'Shop' !== $entries[$x]['sn'][0] && 'Account' !== $entries[$x]['sn'][0]){ $ad_users[strtoupper(trim($entries[$x]['samaccountname'][0]))] = array('email' => strtolower(trim($entries[$x]['mail'][0])),'first_name' => trim($entries[$x]['givenname'][0]),'last_name' => trim($entries[$x]['sn'][0])); } } } ldap_unbind($ldap_connection); // Clean up after ourselves. } $message .= "Retrieved ". count($ad_users) ." Active Directory users\n"; ?> the javascript that has been used here : $('.leaderboard li').on('click', function () { $.ajax({ url: "../popupData/activedirectory.php", // your script above a little adjusted type: "POST", data: {id:$(this).find('.parent-div').data('id')}, success: function(data){ console.log(data); data = JSON.parse(data); $('#popup').fadeIn(); //whatever you want to fetch ...... // etc .. }, error: function(){ alert('failed, possible script does not exist'); } }); });
  20. Hello sorry if the English is not good Is there any way to get client's timezone or hours difference using PHP and JAVASCRIPT so the time is displayed based on the client's timezone, because I've created a small PHP script and when I upload it to the server, the time was displayed based on the server's timezone. Thank's in advance, Have a good day.
  21. Hi, How can I put the script more random, not just a count of 5 out of 5 .. I wanted, for example, a count of 5 numbers after 7, after 3, after 6 or 15 etc .... a more random count and not only 5 in 5 or 2 in 2 etc. <script> function handleTickInit(tick) { // update the value every 5 seconds var interval = Tick.helper.duration(5, 'seconds'); // value to add each interval var valuePerInterval = 5; // offset is a fixed date in the past var offset = Tick.helper.date('2017-03-01'); // uncomment lines below (and comment line above) if you want offset be set to the first time the user visited the page // var offset = parseInt(localStorage.getItem('tick-value-counter-offset') || Date.now(), 10); // localStorage.setItem('tick-value-counter-offset', offset); // start updating the counter each second Tick.helper.interval(function(){ // current time in milliseconds var now = Date.now(); // difference with offset time in milliseconds var diff = now - offset; // total time since offset divide by interval gives us the amount of loops since offset var loops = diff / interval; // this will make sure we only count completed loops. loops = Math.floor(loops); // multiply that by the value per interval and you have your final value tick.value = loops * valuePerInterval; }, 1000); } </script> I already used this code, but it did not work very well var x = Math.floor((Math.random() * 15) + 1); I wanted to deploy in my script, something like this https://jsfiddle.net/os30L03q/ I do not know if they can help me. Best Regards
  22. Is there away to get something unique on a client computer? I read about ActiveX but it is only works on IE. I need something that can work on other browsers also, maybe on PHP or on Javascript.
  23. <input id="numb" type="number" /> <input type="submit" onclick="myFunction()" /> <p id="demo"></p> <script> function myFunction(){ var x = document.getElementById('numb').value; var regex=/^[1-9]+$/; if (x == ""){ document.getElementById('demo').innerHTML = "Input is Missing"; } else if (!x.match(regex)){ document.getElementById('demo').innerHTML = "Input Incorrect"; } else { document.getElementById('demo').innerHTML = "Input OK"; } } /* if (x == "") { document.getElementById('demo').innerHTML = "Input is Missing"; } else if (isNaN(x)) { document.getElementById('demo').innerHTML = "Input Incorrect"; } else { document.getElementById('demo').innerHTML = "Input OK"; } } */ </script> When input type is "text" it works fine. but when i change input type to "number" and then if i type letters or letters plus numbers. it says "input missing" How can i get correct output while using input type "number" ? Please guide. Thankyou.
  24. links in header looks like.. <link rel="icon" href="images/favicon.ico"> <link rel="shortcut icon" href="images/favicon.ico" /> <link rel="stylesheet" href="css/style.css"> <script src="js/jquery.js"></script> <script src="js/jquery-migrate-1.1.1.js"></script> <script src="js/jquery.easing.1.3.js"></script> <script src="js/script.js"></script> <script src="js/superfish.js"></script> <script src="js/jquery.equalheights.js"></script> <script src="js/jquery.mobilemenu.js"></script> <script src="js/tmStickUp.js"></script> <script src="js/jquery.ui.totop.js"></script> <script src="js/validjs.js"></script> <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <link rel="stylesheet" href="css/homestyle.css"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <link href="css/side-slider.css" rel="stylesheet" type="text/css" media="screen"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="js/jquery.side-slider.js"></script> if i comment the below jq library.. <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script> then my stuck-container works on scroll down the page.. but my "username checker" plugin does not work.. and... VICE-VERSA... Please help me to get out of this prob...
  25. Hi guys, I have a video into a bootstrap modal form that is opened on click. Now when i close the modal i want that video to stop playing. I've manage to do some javascript to do that but instead of stopping the the video i want it stops all the video from that page. How can i target in the script below only the ID of the modal that i want to be stoped from playing? <script> $('body').on('hidden.bs.modal', '.modal', function () { $('video').trigger('pause'); }); </script>
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.