Jump to content

Search the Community

Showing results for tags 'javascript'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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 (PhpStorm, VS Code, 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi all, I am new to PHP and a bit slow in understanding ajax, javascript. I want to ask on how to display the table after I select the 3rd dropdown. I don't know how to start. //this is ajax-dd3.php file <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title></title> <META NAME="DESCRIPTION" CONTENT=""> <META NAME="KEYWORDS" CONTENT=""> <script type="text/javascript"> function ajaxFunction(choice) { var httpxml; try { // Firefox, Opera 8.0+, Safari httpxml=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { httpxml=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpxml=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } function stateChanged() { if(httpxml.readyState==4) { //alert(httpxml.responseText); var myObject = JSON.parse(httpxml.responseText); for(j=document.myForm.state.options.length-1;j>=0;j--) { document.myForm.state.remove(j); } var state1=myObject.value.state1; var optn = document.createElement("OPTION"); optn.text = 'Select State'; optn.value = ''; document.myForm.state.options.add(optn); for (i=0;i<myObject.state.length;i++) { var optn = document.createElement("OPTION"); optn.text = myObject.state[i]; optn.value = myObject.state[i]; document.myForm.state.options.add(optn); if(optn.value==state1){ var k= i+1; document.myForm.state.options[k].selected=true; } } ////////////////////////// for(j=document.myForm.city.options.length-1;j>=0;j--) { document.myForm.city.remove(j); } var city1=myObject.value.city1; //alert(city1); for (i=0;i<myObject.city.length;i++) { var optn = document.createElement("OPTION"); optn.text = myObject.city[i]; optn.value = myObject.city[i]; document.myForm.city.options.add(optn); if(optn.value==city1){ document.myForm.city.options[i].selected=true; } } /////////////////////////// document.getElementById("txtHint").style.background='#00f040'; document.getElementById("txtHint").innerHTML='done'; //setTimeout("document.getElementById('txtHint').style.display='none'",3000) } } var url="ajax-dd3ck.php"; var country=myForm.country.value; if(choice != 's1'){ var state=myForm.state.value; var city=myForm.city.value; }else{ var state=''; var city=''; } url=url+"?country="+country; url=url+"&state="+state; url=url+"&city="+city; url=url+"&id="+Math.random(); myForm.st.value=state; //alert(url); document.getElementById("txtHint2").innerHTML=url; httpxml.onreadystatechange=stateChanged; httpxml.open("GET",url,true); httpxml.send(null); document.getElementById("txtHint").innerHTML="Please Wait...."; document.getElementById("txtHint").style.background='#f1f1f1'; } </script> </head> <body > </head> <body> <div id="txtHint" style="width : 100px;background-color: #cccc33;">Message area</div> <br><br> <form name="myForm" action='ajax-dd3-details.php' method='post'"> <input type=hidden name=st value=0> <table width=500> <tr><td > Select Country<br><select name=country id='s1' onchange=ajaxFunction('s1');> <option value=''>Select One</option> <?Php //require "../include/z_db1.php"; require "config.php";// connection to database $sql="select distinct country from student5 "; foreach ($dbo->query($sql) as $row) { echo "<option value=$row[country]>$row[country]</option>"; } ?> </select> </td><td ><select name=state onchange=ajaxFunction('s2');> <option value=''>Select One</option></select></td> <td ><select name=city onchange=ajaxFunction('s3');> <option value=''>Select One</option></select></td> </tr></tr> <tr><td colspan=3><input type=submit value='Submit'></td></tr> </form> </table> <br><br> <div id="txtHint2"></div> </body> </html> //this is ajax-dd3ck.php file <?Php require "config.php"; // connection details error_reporting(0);// With this no error reporting will be there ////////// ///////////////////////////////////////////////////////////////////////////// $country=$_GET['country'];// //$country='IND'; // To check you can use this $state1=$_GET['state']; $city1=$_GET['city']; ///////////// Validate the inputs //////////// // Checking country variable /// if((strlen($country)) > 0 and (!ctype_alpha($country))){ echo "Data Error"; exit; } // Checking state variable (with space ) /// if ((strlen($state1)) > 0 and ctype_alpha(str_replace(' ', '', $state1)) === false) { echo "Data Error"; exit; } /////////// end of input validation ////// if(strlen($country) > 0){ $q_country="select distinct(state) from student5 where country = '$country'"; }else{ $q_country="select distinct(state) from student5"; } //echo $q_country; $sth = $dbo->prepare($q_country); $sth->execute(); $state = $sth->fetchAll(PDO::FETCH_COLUMN); $q_state="select distinct(city) from student5 where "; if(strlen($country) > 0){ $q_state= $q_state . " country = '$country' "; } if(strlen($state1) > 0){$q_state= $q_state . " and state='$state1'";} $sth = $dbo->prepare($q_state); $sth->execute(); $city = $sth->fetchAll(PDO::FETCH_COLUMN); $main = array('state'=>$state,'city'=>$city,'value'=>array("state1"=>"$state1","city1"=>"$city1")); echo json_encode($main); ////////////End of script ///////////////////////////////////////////////////////////////////////////////// ?> //this is ajax-dd3-details.php file <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title></title> <META NAME="DESCRIPTION" CONTENT=""> <META NAME="KEYWORDS" CONTENT=""> </head> <body> <?Php echo "Country : $_POST[country]<br> State : $_POST[state]<br> City : $_POST[city]<br> <br><br><br> Return to <a href=ajax-dd3.php>Drop down list</a> "; ?> </body> </html>
  2. I have tried other players and am now testing the mediaelement.js player, which works in all browsers, playing the video, and shows the 'poster' image in all browsers, except no 'poster' image appears in IE8. As I know the "poster' isn't supported by IE8, I'm looking for help with a work-around to place a thumbnail image as a substitute (for IE8) for the 'poster' image. Any help will be appreciated. Here's my current code: <video id="video" poster="http://www.-domain-.com/img/testImage.jpg" preload="none" controls="controls" width="240" height="220" > <source type="video/mp4" src="http://www.-domain-.com/video/testVideo.mp4"/> <object width="240" height="220" type="application/x-shockwave-flash" data="http://www.-domain-.com/mediaelement/flashmediaelement.swf"> <param name="movie" value="http://www.-domain-.com/mediaelement/flashmediaelement.swf" /> <param name="flashvars" value="controls=true&file=http://www.-domain-.com/video/testVideo.mp4" /> <!-- Image as a last resort --> <img src="http://www.-domain-.com/img/testImage.jpg" width="240" height="220" title="No video playback capabilities" /> </object> </video>
  3. Hi all, I need some guidance on how I can build an AJAX/PHP chat application, sort of like an instant messaging thing like the one on Facebook. It doesn't have to be anything fancy as long as it works. I have some ideas as to how I can build it but I've never tried to do anything like this before so I'm a bit lost. I'm confident I can build the entire PHP side of things up until I have to use AJAX, then I'm stuck. The main concern I have is the affect it will have on the server, lets say I have a Javascript timer to check for new messages sent at certain intervals, wouldn't that have a massive affect on the server? I can only think of using a timer to get new messages for each user, I can't come up with any other way to get it to work. I just don't want to kill the server with AJAX requests if that's even possible. So really my question is, would it be okay to use a timer to get new messages of each user at certain intervals, or is there another way of doing it? Hope this makes sense Thanks, Adam
  4. Hello, I could not figure wether this question should be posted in the javascript forum or here. I am building a simple blog commenting application that displays a comment reply box whose textarea has a dynamically generated ID when a reply link is clicked Take a look at my html code below: <div> <div> Some message over here </div> <div style = "height:10px;"> <a class="reply" id="myHeader1" href="javascript:showonlyone('newboxes1');" >Reply</a></div> </div> <div class ="replymsgbox" id="newboxes1"> <form method="POST"> <textarea id="" class="content"></textarea> </form> </div> <div> <div> Some message over here </div> <div style = "height:10px;"> <a class="reply" id="myHeader2" href="javascript:showonlyone('newboxes2');" >Reply</a></div> </div> <div class="replymsgbox" id="newboxes2"> <form method="POST"> <textarea id="" class="content" ></textarea> </form> </div> And this is the javascript dynamically generating the ID: The javascript script below uses the parent(); children() and next() jquery methods to traverse the DOM and select the textarea element of the displayed form so as to assign the 'ID attribute' to it. <script type="text/javascript"> $('a.reply').on("click", function(e){ $(this).parent("div").parent("div").next("div").children('form').children('textarea').attr( "id", "ckeditor" ); }); </script> When the reply link is clicked, the comment box with a form is toggled using the jquery show() and hide() functions. See code snippet below: <script src="views/js/jquery-1.11.2.min.js" type="text/javascript"></script> <script type="text/javascript"> function showonlyone(thechosenone) { $('.replymsgbox').each(function(index) { if ($(this).attr("id") == thechosenone) { $(this).show(200); } else { $(this).hide(600); } }); } </script> I then wish to replace the dynamic (textarea id="comment") with a CKEditor instance using the code below: <script src="libraries/ckeditor/ckeditor.js"></script> <script type="text/javascript"> $(document).ready(function() { if(CKEDITOR) { // Replace the <textarea id= "ckeditor"> with a CKEditor instance. CKEDITOR.replace('ckeditor'); } }); </script> However, when I toggle the comment form, (the id="ckeditor") attribute is assigned, but what appears is a simple textarea not with ckeditor enabled on it. How can I make each new dynamically created textareas use CKeditor? or Why is the CKEDITOR replace() method not detecting the textarea ID? Perhaps someone here may have any clues? Note: that when I hardcode the id='ckeditor' attribute value pair into any of the text areas, that textarea is converted into a rich text editor.
  5. I got this piece of code from a free template and I followed all the instructions that came with it, everything seems fine but mail doesn't go trough. HTML: <!--Start Contact form --> <form name="enq" method="post" action="email/" onsubmit="return validation();"> <fieldset> <input type="text" name="name" id="name" value="" class="input-block-level" placeholder="Name.." /> <input type="text" name="email" id="email" value="" class="input-block-level" placeholder="Email.." /> <textarea rows="11" name="message" id="message" class="input-block-level" placeholder="Message.."></textarea> <div class="actions"> <input type="submit" value="Send!" name="submit" id="submitButton" class="btn btn-info pull-right" title="Send!" /> </div> </fieldset> </form> <!--End Contact form --> PHP: <?php if(isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $query = $_POST['message']; $email_from = $name.'<'.$email.'>'; $to="email@sample.com"; $subject="Enquiry!"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$email_from."\r\n"; $message=" Name: $name <br> Email-Id: $email <br> Message: $query "; if(mail($to,$subject,$message,$headers)) header("Location:../contact.php?msg=Successful Submission! Thankyou for contacting us."); else header("Location:../contact.php?msg=Error To send Email !"); //contact:-your-email@your-domain.com } ?> JavaScript function validation() { var contactname=document.enq.name.value; var name_exp=/^[A-Za-z\s]+$/; if(contactname=='') { alert("Name Field Should Not Be Empty!"); document.enq.name.focus(); return false; } else if(!contactname.match(name_exp)) { alert("Invalid Name field!"); document.enq.name.focus(); return false; } var email=document.enq.email.value; //var email_exp=/^[A-Za-z0-9\.-_\$]+@[A-Za-z]+\.[a-z]{2,4}$/; var email_exp=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; if(email=='') { alert("Please Enter Email-Id!"); document.enq.email.focus(); return false; } else if(!email.match(email_exp)) { alert("Invalid Email ID !"); document.enq.email.focus(); return false; } var message=document.enq.message.value; if(message=='') { alert("Query Field Should Not Be Empty!"); document.enq.message.focus(); return false; } return true; } I don't get any errors but mail doesn't simply go trough, checked spam etc.
  6. How can i Add Screen Resolution to PHP Variable and Echo it? i am quite confused on how to do this as getting resolution is done in javascript right? Please help me with this. i have coded my first wordpress theme and this is the only part i am stuck at p.s. I want to save screen height in different variable and screen width in different variable.
  7. Wasnt sure whether to put this in Javascript or CSS, sorry... I'm using Skrollr at this dev URL (http://workwave.joomlatest01.mms-dev.com/) to make all the desk items "slide away" NOTE: things are messy currently but you get the gist of what happens (i.e. the clutter moves away and the software on the monitor replaces it) I'm using this "helper" function, found here (https://www.bram.us/2014/01/01/skrollr-css-animations-linked-to-scroll-position/)... var setSkrollr = function($el, data) { for (var i = 0, l = data.length; i < l; i++) { // loop all data entries (scroll positions + css property & value) var d = data[i], // the current data entry px = d[0]; // the scroll position (in pixels) css = d[1]; // the css property + value to set $el.attr('data-' + px, css); } } So the skrollr code for these moving desk items looks like this currently... jQuery(function($) { setSkrollr($('#t3-mainnav'), [[0, 'height: 100px'], [300, 'height: 50px']]); setSkrollr($('#t3-mainnav .container'), [[0, 'top: 25px; height: 100px'], [300, 'top: 0px; height: 50px ']]); setSkrollr($('#filecabinet'), [[0, 'top: -60px; left: 60%; display: block;'], [300, 'top: 280px; left: 200%; display: none']]); setSkrollr($('#calculator'), [[0, 'top:520px; left:0%'], [300, 'top:700px; left:-200%']]); setSkrollr($('#stapler'), [[0, 'top:440px; left:12%'], [300, 'top:700px; left:-200%']]); setSkrollr($('#pens'), [[0, 'top:280px; left:38%;'], [300, 'top:580px; left:-200%; ']]); setSkrollr($('#postits'), [[0, 'top:470px; left:70%; display: block;'], [200, 'top:700px; left:200%; display: none;']]); setSkrollr($('#cup'), [[700, 'top:640px'], [1800, 'top:-500px'] ]); setSkrollr($('#map'), [[0, 'top:530px; left:73%; display: block'], [200, 'top:700px; left:200%; display: none; ']]); setSkrollr($('#calendar'), [[0, 'top:500px; left:22%;display: block'], [300, 'top:740px; left:-200%; ']]); setSkrollr($('#monitor'), [[0, 'display:none'], [100, 'display:block; top: 100%'], [300, 'top:11%; position: fixed'], [700, 'top:11%'], [1600, 'top:-100%'] ]); setSkrollr($('#headline'), [[700, 'top:90px'], [1800, 'top:-400px'] ]); setSkrollr($('#desk'), [[700, 'top:560px'], [1800, 'top:-500px'] ]); setSkrollr($('.toplink'), [[0, 'display:block'], [10, 'display:none']]); skrollr.init({ smoothScrolling: false }); I can change the size of the images based on screen resolution using CSS Media Queries and "scale" to reduce the size of the images as the screen width decreases. But right now things are POSITIONED using that skrollr helper function above and I can't change the positions based on screen resolutions. In other words, whatever position I specify in the helper function is the position always. So I can say start the map 85% from the left and it will always be 85% from the left regardless of screen size. So visually it starts in different spots, i.e. if things are positioned OK on a 1920 monitor, when you go down to a 1024 monitor, things are not ideally positioned. It would be a lot of work, but if I could adjust starting/ending positions in media queries, I could make things look perfect at pretty much every resolution. Anyone know if this is possible? I'm new to Skrollr so may just be missing something. Or if anyone has other ideas on how to do this animation easier/more efficiently, please let me know. Thanks!
  8. So I have a simple script that adds and returns mysql data without refreshing the page. Everything works as it should. The only issue that I've noticed is that if I login as a user and insert a record(text) the FIRST time, it won't return that record in the row below. Not until I refresh the page. Now if I delete that record and insert a new record, it will then automatically return the record without the page refresh, as it should. Can you tell me why this is happening? Here is my js code. <script> $(document).ready(function(){ var recordId = $("#record-id").val(); function showRecord(){ $.ajax({ type: "POST", url: "bid-actions.php", data: "recordId="+recordId+"&action=showRecord", success:function(data){ $(".show-records").html(data); } }); } showRecord(); $(document).on('click','#record-submit',function() { var message = $("#message").val(); var recordId = $("#record-id").val(); $.ajax({ type: "POST", url: "bid-actions.php", data: "message="+message+"&recordId="+recordId+"&action=insertRecord", success:function(data){ showRecord(); $("#message").val(''); } }); }); }); </script> Html code. <div id="record-submit-form"> <input type="hidden" id="record-id" value="<?php echo $record_id; ?>"> <textarea id="message"></textarea> <input type="button" id="record-submit" value="Submit"> </div> <div class="show-records"> </div>
  9. I have created a countdown clock that will be counting down from 100 (looping each second). This is the code: <script> $(document).ready(function(){ $("#buttonClick").on('click', function(){ var initialValue = $("#countdown").text(); setInterval(function () { initialValue--; $("#countdown").text(initialValue); }, 1000); }); }); </script> <body> <button id="buttonClick">Click Me</button> <div id="countdown">100</div> </body> When i click the "Click Me" button the number counts down from 100, 99, 98,97.... When try this from a mobile device and while the device is awake, it works just fine. Lets say the counter is on 50 and i press the power button of the mobile device and it sleeps. If i wake the mobile after 40 seconds, i will not see the remaining 10 seconds but something like 40 or 38 seconds. This happens every time and i don't know why. Can someone help? Regards, Christos
  10. This is jquery dialog box. http://jqueryui.com/dialog/#modal-confirmation I am wondering where would be the best place to add the dialog box div, in below html page? <html> <head> </head> <body> </body> </html>
  11. I want to make my script go full screen like youtube videos do just not sure how to make it happen. <?php $search_text = htmlspecialchars($_GET["keyword"]);?> <?php $profile = htmlspecialchars($_GET["profile"]);?> <?php include_once "header.php";?> <title>Space Search</title> <script src="http://www.worldwidetelescope.org/scripts/wwtsdk.aspx"></script> <script> var wwt; function initialize() { wwt = wwtlib.WWTControl.initControl("WWTCanvas"); wwt.add_ready(wwtReady); wwt.endInit(); } function wwtReady() { wwt.loadImageCollection("http://www.worldwidetelescope.org/COMPLETE/wwtcomplete.wtml"); wwt.gotoRaDecZoom(286.485, -27.5231666666667, 60, false); wwtControl.settings.set_solarSystemStars(true); } </script> </head> <div class="header"> <div class="headerwidth"> <div id="searchwrapper"> <div id="search"> <form name="SearchForm" method="get" action="info.php"> <? include_once "menu.php"; ?> <body onload="initialize()"> <div id="WWTCanvas" style="width:1250px; height:540px; margin-left:4%; margin-right:4%; margin-bottom:2.5%; border-style: none; border-width: 0px;"></div> <?php include_once "footer.php";?>
  12. Say I have button 1 and I want to replace it with button2 on click. How would I do that? <button id="button1">butto 1</button> <button id="button2">butto 2</button>
  13. This twitter style button I found. http://jsfiddle.net/jakie8/ZECEN/ I have managed to modify it to my liking. And yes I know the ".live" is depreciated and instead use "on". Anyways, the only thing I noticed is that if I click "Follow" button and it turns green; once I refresh the page, it goes back to default "follow" mode. I was wondering how can I keep it green even if I refresh the page?
  14. I'm creating a social network site using Laravel. I have a page that load all the posts created by users the currentUser follows. I have a comment section on each post. I'm using ajax to post the comments. Here is my code. Here is the view of the comment-box. It contains a section where I loop through each comment and display them. At the end is the type field so a user can post a new comment: <div class="comment-box-container ajax-refresh"> <div class="comment-box"> @if ($type->comments) @foreach ($type->comments as $comment) <div class="user-comment-box"> <div class="user-comment"> <p class="comment"> <!-- starts off with users name in blue followed by their comment--> <span class="tag-user"><a href="{{ route('profile', $comment->owner->id) }}">{{ $comment->owner->first_name }} {{ $comment->owner->last_name }}</a> </span>{{ $comment->body }} </p> <!-- Show when the user posted comments--> <div class="com-details"> <div class="com-time-container"> {{ $comment->created_at->diffForHumans() }} · </div> </div> </div><!--user-comment end--> </div><!--user-comment-box end--> @endforeach @endif <!--type box--> <div class="type-comment"> <div class="type-box"> {{ Form::open(['data-remote', 'route' => ['commentPost', $id], 'class' => 'comments_create-form']) }} {{ Form::hidden('user_id', $currentUser->id) }} {{ Form::hidden($idType, $id) }} {{--{{ Form::hidden('user_id', $currentUser->id) }}--}} {{ Form::textarea('body', null, ['class' =>'type-box d-light-solid-bg', 'placeholder' => 'Write a comment...', 'rows' => '1']) }} {{ Form::close() }} </div><!--type-box end--> </div><!--type-comment--> </div><!--comment-box end--> The user submit the form for the comment type box by pressing the "enter/return" key. Here is the JS for that <script> $(document).on('keydown', '.comments_create-form', function(e) { if (e.keyCode == 13) { e.preventDefault(); $(this).submit(); } }); </script> Here is my Ajax (function(){ $(document).on('submit', 'form[data-remote]', function(e){ e.preventDefault(); var form = $(this) var target = form.closest('div.ajax-refresh'); var method = form.find('input[name="_method"]').val() || 'POST'; var url = form.prop('action'); $.ajax({ type: method, url: url, data: form.serialize(), success: function(data) { var tmp = $('<div>'); tmp.html(data); target.html( tmp.find('.ajax-refresh').html() ); target.find('.type-box').html( tmp.find('.type-box').html() ); tmp.destroy(); } }); }); })(); When I post a comment on the first post it all works fine. However, when I post a comment on the second, third, fourth etc it only displays the comments from the first post. I have to manually refresh the page, then the correct comments will display. I'll try to illustrate this problem with images. Starting fresh, I can easily submit 2 comments on POST 1 http://s27.postimg.org/6ej76hunn/comment1.jpg When I scroll down to Post 2, I see it already has a comment, I will submit a new comment http://s23.postimg.org/x65ui2ryz/comment_2.jpg HERE'S THE PROBLEM: When I submit the comment on POST 2, the comments that were in POST 2 disappears, and are replaced by the comments from POST 1. http://s30.postimg.org/ugl08oz01/comment_3.jpg The back end still worked, because when I reload the page everything is the way it should be http://s9.postimg.org/w51fgyzen/comment_4.jpg I'm completely stuck. Does anyone know why this is happening and how to fix it?
  15. I have a very troubling problem at hand. I am using a web-socket server that runs in PHP. The issue is I need to be able to use a setInterval/setTimeout function similar to javascript, but within my php server. I do not have the time or resources to convert my entire project over to nodejs/javascript. It will take forever. I love php so much, that I do not want to make the switch. Everything else works fine and I feel like it's not worth it to re-write everything just because I cannot use a similar setInterval function inside php. Since the php socket server runs through the shell, I can use a setInterval type function using a loop: protected function on_server_tick($counter) { if($counter%5 == 0) { // 5 seconds interval } if($counter%10 == 0) { // 10 seconds interval } } $this->last_tick_time = microtime(true); $this->tick_interval = 1; $this->tick_counter = 0; while(true) { //loop code here... $t= microtime(true) - $this->last_tick_time; if($t>= $this->tick_interval) { $this->on_server_tick(++$this->tick_counter); $this->last_tick_time = microtime(true) - ($t- $this->tick_interval); } } This code does work as intended, but it seems a bit overboard for resources and I feel like that while loop will suck a lot resources. Is there anyway I can re-compile PHP from source and include a "while2" loop that only iterates every 500 miliseconds instead of instantly?
  16. Need little help with the quiz problem. I want to set time limit for each question in quiz module (say 30 seconds) and after that time, the form will auto submit the question (auto submit = no option selected = unanswered). There are 3 questions, so total time limit is 90 sec (30 sec each). I'm doing this via XAMPP. The link below provide the work so far https://www.dropbox.com/s/4dzlgjtjzvs48vw/quiz.rar?dl=0 Thanks
  17. Hi, I have a PHP script sendEmail.php that given some data (receiver, content, etc), sends an email to the receiver. When i click the Send button i fire the sendEmail.php script using AJAX: $('#sendbutton').on('click', function(){ $.ajax({ type: "POST", url: "js/ajax/sendEmail.php", data: {receiver:receiver, content: content} }); }); I want to add a feature call "Schedule send" where the user can select in how many minutes the email will be send. What i did, was to take the minutes value, insert it into a countDown timer, and as soon as the time is Zero, to fire the same AJAX call. This is working only if the browser is open. And i can understand this, since it is Javascript's responsibility to fire the AJAX call since its the one on client site. QUESTION: Is there a way to fire this sendEmail.php scipt even if the web browser is closed?Using PHP/MYSQL of course.. For example the user will select the recipient, write the email, schedule it to be sent 20 minutes later, and close the browser. If not, what are your suggestions? Thanks in advance, Christos
  18. I would like to know how can I redirect a jquery dialog function to a different page, if another function is true? For eg. 1. User 1 sends a request to User 2. 2. User 2 accepts the request. 3. User 1 still has the request "dialog" window open. Instead, I would like to have that dialog window close and redirect to a specified page. Of course this only happens after User 2 accepts the request and I check against it in the database. Here is the function for when User 1 makes a request. <script> $(function() { $("#new-dialog").dialog({ resizable: true, autoOpen: false, modal: true, width: 600, height: 300, buttons: { "Cancel Trade": function(e) { $(this).dialog("close"); $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=cancelTrade", success:function(data){ if(data == true) { alert('success'); } else { alert('not deleted'); } //window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; } }); } } }); $(".dialogify").on("click", function(e) { e.preventDefault(); $("#new-dialog").html(""); $("#new-dialog").dialog("option", "title", "Loading...").dialog("open"); $("#new-dialog").load(this.href, function() { $(this).dialog("option", "title", $(this).find("h1").text()); $(this).find("h1").remove(); }); }); }); </script> And here is the new function in which I check the database for match. If it returns true, I would like to redirect the above dialog/page. <script> $('document').ready(function(){ function checkTrade() { $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=checkTrade", success:function(data){ window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; } }); } }); </script> So what am I missing to do the redirect?
  19. Here's the basic premise of the function I am trying to create. 1. User 1 sends a trade request to User 2. 2. User 2 accepts the request. 3. It redirects both users to new page(trade.php). Below is the code where User 2 accepts the request.I am using jquery dialog box for pop windows. The current issue I am having is that "window.location." is not showing the "by=$session_requestById" variable. It appears as NULL if I var_dump on trade.php page. But it is showing the second variable correctly, which is "by=$session_requestToId". It seems like it only happens on trade.php page. Both variables show up fine on request-php.page and in heading when I var_dump. Perhaps you can tell me what's wrong with this ? window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; <script> $(function() { $( "#dialog-confirm" ).dialog({ resizable: true, autoOpen: true, modal: true, width: 600, height: 300, buttons: { "Accept Trade": function() { $( this ).dialog( "close" ); $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=acceptTrade", success:function(data){ window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; } }); }, Cancel: function() { $( this ).dialog( "close" ); $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=cancelTrade", success:function(data){ if(data == false) { alert('not cancelled'); } else { alert('cancelled success'); } } }); } } }); }); </script>
  20. Below, I have set .navbar to animate after 4 seconds but I have a bit of a problem. I want the navbar to slide down into view. It seems that it's not animating from the top of the page. It 'appears' and then animates on the last few pixels. see: http://black-dog-dev.sites.ac <style type="text/css"> .navbar { display:none; min-height:auto; } video{ width:100%!important; height:auto!important; visibility:hidden; position:fixed; z-index:-20; } #videoclip{ width:100%; position:fixed; z-index:-20; } #space{ width:100%; height:640px; opacity:1.0; filter:alpha(opacity=100); } #opacity{ width:100%; height:450px; color:#fff; opacity:1.0; filter:alpha(opacity=100); } .parallax-main-banner { height:auto; } @media (max-width: 990px){ #opacity{ height:288px; } .parallax-main-banner { min-height: 310px; } video#my_video { width: 130%!important; } } @media (max-width: 760px){ #opacity{ height:168px; } .parallax-main-banner { min-height: 310px; } } </style> <script type='text/javascript'> var resize_home_page_image_divs = function() { jQuery('.field-name-field-landing-page-image img').each( function(i, el) { var el1 = jQuery(el); var h = parseInt(el1.height()*2/3)+'px'; el1.parent().parent().parent().css('height', h).css('overflow','hidden'); } ); } jQuery(document).ready(function(){ jQuery(window).resize( function() { resize_home_page_image_divs(); } ); jQuery(window).scroll( function(ev) { var h = jQuery(window).scrollTop(); var wh = jQuery(window).height(); jQuery('.field-name-field-landing-page-image img').each( function(i, el) { var el1 = jQuery(el); var h1 = parseInt(el1.height()); var off1 = el1.offset(); var mt = 0; if (wh>off1.top-h) { mt = parseInt(h1/3)-parseInt(h1/3*(off1.top-h+h1)/(h1+wh)); } if (off1.top+h1-h<0) { mt = parseInt(h1/3); } mt = -mt; el1.css('margin-top', mt+'px'); } ); } ); jQuery('#space').delay(4000).slideUp("slow"); jQuery('.navbar').delay(4000).slideDown("slow"); setTimeout(function() { jQuery('body').scrollTo(10).scrollTo(0); resize_home_page_image_divs(); },4500); }); </script> can anyone explain where i'm going wrong? I can supply source code, but its a rather big file. Many thanks.
  21. i am creating a responsive website. I'll give you an example. I am retriving 100 items from mysql database using php. I am only showing 20 items per page using simple pagination with arrows. I keep this format on desktop and tablets. However, I would like to show less items when I am viewing the page on a smartphone. So instead of 20 items per page, it'll show 5 items per page along with the pagination arrows. I was wondering if this is possible with PHP or would I have to use javascript?
  22. Hello, I want to download flight from Wizzair page. I've checked all headers which are sended when browser "create" request (the same which Ryanair few months ago). It looks like this in my browser: I'm entering at https://wizzair.com/pl-PL/Search, select everything (from-to, date arrival and departure) then click "Send" and I've got results. I've checked headers and I can see, that theres two requests to the following pages: 1) Search (here is created session ID saved in cookie, i've also sent POST parameters here), it returns error 302 then redirect to: 2) Select (theres no any post or get parameters, just requested session ID created before) and return results with flights. I was trying to achieve the same results by curl. I created curl request with the same POST parameters to Search page. I save sessionId to cookie, also create the same cookies as in browser. Then enter to Select page, use cookies saved before but nothing happens. First request return 302 error (the same happen in brower) Second request returns default Wizzair website without flight results If I use sessionId generated in my browser (not from curl request), second request show me correct results. Why it doesn't work in curl? Is there any request processed and saved JavaScript which is not processed by curl method? Code from my first requst where i'm sending post parameters in request $fields = array( 'cookiePolicyDismissed' => 'true', '__EVENTTARGET' => 'HeaderControlGroupRibbonSelectView_AvailabilitySearchInputRibbonSelectView_ButtonSubmit', '__VIEWSTATE' => '/wEPDwUBMGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFXEhlYWRlckNvbnRyb2xHcm91cFJpYmJvblNlbGVjdFZpZXckQXZhaWxhYmlsaXR5U2VhcmNoSW5wdXRSaWJib25TZWxlY3RWaWV3JFN0dWRldFNlbmlvckdyb3VwwAw35gayQedhYJ8oz+CHlR8x2gWGvNOEfHfCOBjF/lk=', 'cff49415-63b6-4d31-b273-5eab61b6c327' => 'e2df7ef6-3abf-4eab-8110-51c30f30109a', 'HeaderControlGroupRibbonSelectView%24AvailabilitySearchInputRibbonSelectView%24OriginStation' => $from, 'HeaderControlGroupRibbonSelectView%24AvailabilitySearchInputRibbonSelectView%24DestinationStation' => $to, 'HeaderControlGroupRibbonSelectView%24AvailabilitySearchInputRibbonSelectView%24DepartureDate' => $dateStart, 'HeaderControlGroupRibbonSelectView%24AvailabilitySearchInputRibbonSelectView%24ReturnDate' => $dateBack, 'HeaderControlGroupRibbonSelectView%24AvailabilitySearchInputRibbonSelectView%24PaxCountADT' => '1', 'HeaderControlGroupRibbonSelectView%24AvailabilitySearchInputRibbonSelectView%24PaxCountCHD' => '0', 'HeaderControlGroupRibbonSelectView%24AvailabilitySearchInputRibbonSelectView%24PaxCountINFANT' => '0', 'WizzSummaryDisplaySelectViewRibbonSelectView%24PaymentCurrencySelector' => '00000000-0000-0000-0000-000000000000FULL', 'HeaderControlGroupRibbonSelectView%24AvailabilitySearchInputRibbonSelectView%24ButtonSubmit' => 'Szukaj'); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0'); curl_setopt($ch, CURLOPT_HEADER,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Host: wizzair.com', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/*;q=0.8', 'Accept-Language: pl,en;q=0.7,en-us;q=0.3', 'Connection: keep-alive' )); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($ch); curl_close($ch);
  23. Hi; I'm a beginner and I'm getting a big headache figuring how to convert php variables into Javascript variables. I want to use the content of $theName as the value for an input tag. $_SESSION['$Sess_Name'] is loaded with the right data, I verified it. But my function InitField returns always the word NULL. Why is that? Where is the problem? Thank Here is my code: function InitField() { <?php $theName = $_SESSION['$Sess_Name']; ?> var tempoVar = "<?php echo json_encode($theName); ?>"; var myInput = document.getElementById('theSurname'); myInput.value = tempoVar; }
  24. So I have been working on my website for a while which all is php&mysql based, now working on the social networking part building in similar functions like Facebook has. I encountered a difficulty with getting information back from a link. I've checked several sources how it is possible, with title 'Facebook Like URL data Extract Using jQuery PHP and Ajax' was the most popular answer, I get the scripts but all of these scripts work with html links only. My site all with php extensions and copy&paste my site links into these demos do not return anything . I checked the code and all of them using file_get_contents(), parsing through the html file so if i pass 'filename.php' it returns nothing supposing that php has not processed yet and the function gets the content of the php script with no data of course. So my question is that how it is possible to extract data from a link with php extension (on Facebook it works) or how to get php file executed for file_get_contents() to get back the html? here is the link with code&demo iamusing: http://www.sanwebe.com/2013/06/extract-url-content-like-facebook-with-php-and-jquery thanks in advance.
  25. Hi, I'm trying to submit a form to itself and then have go on to another page. I've tried a few things but the form only returns to itself. How can I redirect the form after posting to itself. My HTML code is between <?php ?> tags. <head> <title>untitled</title> <script src="respond.min.js"></script> </head> <body> <form id= "formId" action="goToUrl.com" method ="post"> Name: <input type = "text" name ="firstName" value=""/> <input id="formButton" onClick="self.location='www.msn.com'" type="submit" name="submit" value="Submit" /> <br/> </form> </div> </body> </html> also tried puting this script just after the closing form tag: <script type="text/javascript"> $('#formButton').click(function(){ location="www.google.com" }); </script> In both cases the form seems to ignore the script. Thanks for any help with this!
×
×
  • 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.