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, This problem is killing me. I hope / pray someone can help. Essentially I need to pass a JS variable to a PHP variable without refresh/form submission or redirecting. I'm new to Ajax so please be patient The owner of this site generally lives in 3 countries lucky ******. When he logs in he wants the contact page updated with his current number. I have a form with hidden fields that return the address location using an ajax call to ipinfo.io - this works fine. <script> $(function() { var admin = <?php echo json_encode($admin->isAdmin($user['username'])); ?>; var phone=""; if(admin == true){ $.ajax({ url:"http://ipinfo.io", dataType:'jsonp' }) .success(function(response){ $("#address").val(response.country); $("input[id=address]").val(response.country); var testLoc = $('#address').val(); if(testLoc == "GB"){ phone = "<?php echo $gb?>"; $("#phone").append(phone); }else if(testLoc == "GABON"){ phone = "<?php echo $gabon?>"; $("#phone").append(phone); }else if(testLoc == "THAILAND"){ phone = "<?php echo $thai?>"; $("#phone").append(phone); } }); var time = new Date(); $("#localTime").append(time); }else{ //alert("Not Admin"); $("#phone").append(phone); } }); </script> The above essentuially checks to see that he is THE admin, if it is it then sets the hidden field value to be the country, that is then placed in the testLoc variable and depending on what it is, it spits out the number. This all works well unless of course you visit the site and you're not the admin. All you see is an empty string. I need to get that phone variable or location variable, either of them really from the js into a php variable. That way when a normal joey visits the page I can just echo out that variable instead. phone or location var in js script to php variable?
  2. <link type="text/css" href="assets/css/main.css" rel="stylesheet" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="assets/js/google_maps/jquery-1.9.1.js"></script> <script type="text/javascript" src="assets/js/google_maps/jquery-ui-1.10.3.custom.min.js"></script> <script type="text/javascript" src="assets/js/google_maps/main.js"></script> <script> function updatelocation(){ var lat = document.getElementById('latitude').value; var long = document.getElementById('longitude').value; newlocation = lat+ "," +long; alert(newlocation); } </script> <div class="row"> <div class="large-12 small-6 columns"> <label>Address: </label><input id="address" type="text"/> <div id="map_canvas" style="width:100%; height:300px"></div> <br/> <label>latitude: </label><input id="latitude" type="text"/><br/> <label>longitude: </label><input id="longitude" type="text"/> <input name="setlocation" type="button" onClick="javascript:updatelocation()" value="Set As Your Location"> </div> </div> Here is my code can some one help me? The display should be right next to the address textbox.
  3. Hello, I'm trying to retrieve dates from the database based on a selection. If a user selects singer A for example, then I'm going through the database and get the unavailable dates of singer A. var unavailableDates; function unavailable(date) { dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear(); if ($.inArray(dmy, unavailableDates) == -1) { return [true, ""]; } else { return [false, "", "Unavailable"]; } } $(document).ready(function() { $("#datepicker").datepicker({ dateFormat: 'yy-mm-dd', beforeShowDay: unavailable, minDate: 0, firstDay: 1, // rows starts on Monday changeMonth: true, changeYear: true, showOtherMonths: true, selectOtherMonths: true, altField: '#date_due', altFormat: 'yy-mm-dd' }); $('#datepicker').focus(function(){ //alert($('#name').html()); $.ajax({ url: 'getDates.php', data: "artist_id="+$('#name').html(), dataType: 'json', success: function(data) { alert(data) } }); }) }); Everything works fine. Using the "getDates.php" I retrieved the dates and pass them through the function. But how can I pass the data (after success: function) to the unavailable dates above? I have the dates from database but I don't know how to link them with the array "unavailableDates" (line 1) in order to show unavailable dates in datePicker.
  4. Hello all, Im working on a back-end system that sends push notifications. At the moment on click of send button the loading gif appears underneath. I would like the send button to disappear and for the loading gif to appear as it is now. How can I implement this feature ? Any help would be much appreciated <div class="row-fluid"> <input type="submit" name="badgeSubmit" class="span5 offset7 blue-button" value="Send" onClick='return checkvalue() && toggle(); return false;' /> <img style="position:relative; top:20px;"src="/images/sending.gif" alt="loading" class="sending"> </div>
  5. Hello, I am trying to create an array where by the items listed are nested with the names and the array spat out is easy to use when I am creating an ajax function with data from it all. Below is an idea of what I need to do: # This is where I am grabbing the data from the instagram class $data_url[] = $data->images->standard_resolution->url; $data_link[] = $data->link; $data_id[] = $data->getId(); $data_likes[] = $data->likes->count; {["images":[ ["data_url":[ ["http:\/\/distilleryimage4.s3.amazonaws.com\/f8e5e2fafe8811e2a42922000a9e51c4_7.jpg"] ], ["data_link":[ ["http:\/\/instagram.com\/p\/cq2pjLMNNE\/"] ], ["data_id": [516465457066201924_288233123] ], ["data_likes": [18] ] ] ] } In my current ajax.php page, I am creating a place where data can be captured and I can use it to get the images and place them into a page. Here is what I have got so far: $instagram = new Instagram\Instagram; $instagram->setAccessToken($_SESSION['instagram_access_token']); $token = $_SESSION['instagram_access_token']; //$clientID = $_SESSION['client_id']; $current_user = $instagram->getCurrentUser(); $tag = $instagram->getTag('folkclothing'); $media = $tag->getMedia(isset($_GET['max_tag_id']) ? array( 'max_tag_id' => $_GET['max_tag_id'] ) : null); /* $params = isset( $_GET['max_tag_id'] ) ? array( 'max_tag_id' => $_GET['max_tag_id'] ) : null; */ /* $media = $tag->getMedia($params); */ /* $next_page = $media->getNext(); */ /* // Receive new data $imageMedia = $instagram->pagination($media); */ // Collect everything for json output $images = array(); $data_link = array(); $data_id = array(); $data_likes = array(); foreach ($media as $data) { $images[] = array($data_url[] = $data->images->standard_resolution->url,$data_link[] = $data->link, $data_id[] = $data->getId(), $data_likes[] = $data->likes->count); } echo json_encode(array( 'next_id' => $media->getNextMaxTagId(), 'images' => $images )); Below is what my /ajax/ url gives me: {"next_id":"1374887530845","images":[["http:\/\/distilleryimage4.s3.amazonaws.com\/f8e5e2fafe8811e2a42922000a9e51c4_7.jpg","http:\/\/instagram.com\/p\/cq2pjLMNNE\/","516465457066201924_288233123",18],["http:\/\/distilleryimage10.s3.amazonaws.com\/46f790e0fdaf11e29de622000ae90e7b_7.jpg","http:\/\/instagram.com\/p\/coEUD0MyGO\/","515681128006492558_197168271",23],["http:\/\/distilleryimage6.s3.amazonaws.com\/7e510fa6fcee11e29a4b22000a1fb593_7.jpg","http:\/\/instagram.com\/p\/clmYo1AgU6\/","514986551277651258_20025128",25],["http:\/\/distilleryimage0.s3.amazonaws.com\/4f41be96fc3411e2829822000a9f1487_7.jpg","http:\/\/instagram.com\/p\/cjN3PipYkE\/","514315753313634564_190097401",10],["http:\/\/distilleryimage0.s3.amazonaws.com\/bcc8d83cfb9911e2921e22000aa81fd0_7.jpg","http:\/\/instagram.com\/p\/chPPNdGDhI\/","513758848433535048_6206549",13],["http:\/\/distilleryimage2.s3.amazonaws.com\/ef97af2efb5611e2b16122000a1f9e61_7.jpg","http:\/\/instagram.com\/p\/cgYg4ljpby\/","513518170419402482_52465932",1],["http:\/\/distilleryimage5.s3.amazonaws.com\/8e7bbf04fa9e11e2aea022000a9d0ee7_7.jpg","http:\/\/instagram.com\/p\/ceBeGXNpA9\/","512853874029531197_20203491",2],["http:\/\/distilleryimage4.s3.amazonaws.com\/96dc4444f9f811e2b88d22000a1fd1dd_7.jpg","http:\/\/instagram.com\/p\/cb5gooAgW4\/","512255913931965880_20025128",6],["http:\/\/distilleryimage11.s3.amazonaws.com\/6b80e884f9dc11e29b2522000a9f13d5_7.jpg","http:\/\/instagram.com\/p\/cbibv3JW9H\/","512154423034998599_430907394",20],["http:\/\/distilleryimage7.s3.amazonaws.com\/64f82bd6f95411e2a73522000a1faf50_7.jpg","http:\/\/instagram.com\/p\/cZzAF8syFb\/","511664339442409819_197168271",16],["http:\/\/distilleryimage10.s3.amazonaws.com\/b54645f4f93711e283e622000a1fb86d_7.jpg","http:\/\/instagram.com\/p\/cZbgGrlSzW\/","511560986135964886_187431354",17],["http:\/\/distilleryimage8.s3.amazonaws.com\/a9fc18a2f87111e29c8b22000a9f18f4_7.jpg","http:\/\/instagram.com\/p\/cW5Q5CBrlw\/","510847457153169776_378485429",6],["http:\/\/distilleryimage0.s3.amazonaws.com\/55b6269cf86311e2b5f422000a1f9a34_7.jpg","http:\/\/instagram.com\/p\/cWthoKit5E\/","510795830715407940_203990694",16],["http:\/\/distilleryimage9.s3.amazonaws.com\/bff691e2f82a11e2939b22000a1f9251_7.jpg","http:\/\/instagram.com\/p\/cV_K8mBu9R\/","510591961963884369_256035442",12],["http:\/\/distilleryimage4.s3.amazonaws.com\/5ef4c3c0f73811e2890322000a9e48f1_7.jpg","http:\/\/instagram.com\/p\/cS4nTwwE_U\/","509718699729506260_37194114",34],["http:\/\/distilleryimage8.s3.amazonaws.com\/a1b5f0acf6cb11e2957722000a1f9a39_7.jpg","http:\/\/instagram.com\/p\/cRfiPgmAWQ\/","509326925426591120_453101536",11],["http:\/\/distilleryimage6.s3.amazonaws.com\/4bf62240f68511e29aee22000a9f38e6_7.jpg","http:\/\/instagram.com\/p\/cQl6qiBzdu\/","509073517011482478_5670460",223],["http:\/\/distilleryimage1.s3.amazonaws.com\/d23848d6f61e11e2807c22000a9e06c7_7.jpg","http:\/\/instagram.com\/p\/cPR9_otpGt\/","508704309923713453_20203491",6]]} Can anyone guide me into the best way I can do this so it gives me an array from my ajax.php so I can grab the data and place it into my page better? I have tried numerous techniques but they have not worked at all. Thanks, Mark
  6. I am building a relatively small app in laravel. Currently I am trying to create a load more button to load more images into a container in the view. Would anyone know when clicking load more I get an internal server error? Here is my set up: View for my images: $instagram = new Instagram\Instagram; $instagram->setAccessToken($_SESSION['instagram_access_token']); $token = $_SESSION['instagram_access_token']; //$clientID = $_SESSION['client_id']; $current_user = $instagram->getCurrentUser(); $tag = $instagram->getTag('folkclothing'); $media = $tag->getMedia(isset($_GET['max_tag_id']) ? array( 'max_tag_id' => $_GET['max_tag_id'] ) : null); $liked_media = $current_user->getLikedMedia(); echo '<section id="images">'; foreach ( $media as $item ) { echo '<article class="instagram-image">'; // define the form and set the action to POST to send the data to this script echo '<form class="forms" action="'; echo URL::current(); echo '" method="post">'; $id = $item->getId(); echo '<a class="fancybox" href="' . $item->link . '"><img src="' . $item->images->standard_resolution->url . '" /></a>'; if ( $current_user->likes($item) ){ echo '<button class="ajax instabtn unlike icon-heart" type="submit" name="action" value="Unlike"></button>'; } else { echo '<button class="ajax instabtn like icon-heart" type="submit" name="action" value="Like"></button>'; } echo '<input type="hidden" name="id" value="'; echo $id; echo '">'; echo '<p>'; echo $item->likes->count; echo '</p>'; //echo '<p>'.$item->getId().'</p>'; //echo '<p>By: <em>' . $item->user->username . '</em> </p>'; //echo '<p>Date: ' . date('d M Y h:i:s', $item->created_time) . '</p>'; //echo '<p>$item->comments->count . ' comment(s). ' . $item->likes->count . ' likes. '; echo '</form>'; echo '</article>'; } echo '</section>'; Here the instagram class generates the images and puts them into the div through a loop. Below is a load more button storing the data need in it. Load more button: echo "<br><button id=\"more\" data-maxid=\"{$media->getNextMaxTagId()}\" data-tag=\"{$tag}\">Load more ...</button>"; And then there is an ajax view that stores the relevant data for the images to be found for the next page: <?php // set up autoloader function app_autoloader($class) { include './' . $class . '.php'; } spl_autoload_register('app_autoloader'); // Initialize class for public requests $instagram = new Instagram\Instagram; // Receive AJAX request and create call object $tag = $_GET['tag']; $clientID = $instagram->getApiKey(); $media = $tag->getMedia(isset($_GET['max_tag_id']) ? array( 'max_tag_id' => $_GET['max_tag_id'] ) : null); $call = new stdClass; $call->next_max_id = $maxID; $call->next_url = "https://api.instagram.com/v1/tags/{$tag}/media/recent?client_id={$clientID}&max_tag_id={$media->getNextMaxTagId()}"; // Receive new data $media = $instagram->pagination($call); // Collect everything for json output $images = array(); foreach ($media->data as $data) { $images[] = $data->images->standard_resolution->url; } echo json_encode(array( 'next_id' => $media->getNextMaxTagId, 'images' => $images )); This page finds the tag and gets the media for that tag and finds the next_max_id. In my jquery I use and ajax call to get this data and load the images into my div but instead I get an internal server error like so: Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://client:8888/ajax?tag=client&max_tag_id=1374869525975&_=137571153802 Does anyone have an idea why it would not produce the results? I know its not too far off. Thanks, Mark ajax.blade.php image.blade.php
  7. Hello, I'm here with a question that maybe silly for most of you but I just can't handle it. As I know, there's no way in built in PHP inside JS because diferent kind of languages ( Server Side and Client Side ). But I have a problem that I need help to handle. I have a multilanguage system in my site ( PHP ) and form validations ( JS ). I have the error messages showed by JS instantly, but I can only print text, not a PHP variable info. For example: $(function() { // validate signup form on keyup and submit $("#loginform").validate({ rules: { user: "required", password: "required", }, messages: { user: "Please enter your username or email.", password: "Please enter your password", } }); }); And my multilanguage system uses the following system: $lang['login_error'] = 'Incorrect details provided.'; There is any way to make something like this: $(function() { // validate signup form on keyup and submit $("#loginform").validate({ rules: { user: "required", password: "required", }, messages: { user: <?php echo $lang[login_error']; ?>, password: "Please enter your password", } }); }); I know this doesn't work, but it's to make an easy example in what I need, because depending the language the user as choosen, the error should be there in that language, not only in one language. Could you please help me to handle this ? Thanks in advance.
  8. Developing CART for Online Shopping I am trying to add buttons on html page and the code is working............I have some products in <SELECT> tag i.e. Product 1,Product 2,Product 3,Product 4,Product 5......... I create an array "list_array" and storing all the values in array dynamically... I click on <BUTTON>ADD </BUTTON> and it reads the value from <SELECT> tag and add it into array...........To display all the products, I execute the loop and display all the items in array with a <BUTTON>REMOVE</BUTTON> in-front of every product.......... To delete the particular product, I can select it in <SELECT> tag and then click on delete button..........It removes the element from array .........To display the cart, I am using the loop again, and it shows all the products after clicking the <BUTTON>Display</BUTTON> Now the issue that I am facing here is that I am adding <BUTTON>REMOVE</BUTTON> button when I am displaying the products that have been added in CART, the code of java_script is listed below function display() { string = ""; str=""; for(j=0;j<i;j++) { str = list_array[j]+"_"+j; string = list_array[j]+" <button onclick='remove_me(this)' id="+str+">Remove</button><br>"+string; } document.getElementById('write').innerHTML = "Array:<br> " + string; document.getElementById('i_val').innerHTML = "I: " + i; } Now, I am trying every way to make a code that will help me in removing the product by clicking on <BUTTON>REMOVE</BUTTON>, I hope I have explained everything here, so, help me to fix this issue...............
  9. I have this array that has n elements ---> list_array = new Array(); it contains ['Product 1','Product 2','Product 3','Product 4','Product 5','Product 6','Product 7','Product 8'] what I am trying to do is that starting a loop from j=0 to j<n, I am adding button on html page, now when I click on button, it must remove itself from the page. I want to do this with the help of javascript...Is there anyone who can help ??? If I click on "product 8", the page must display other 7 buttons and it must delete the button itself on the page..... function create() { for(j=0;j<i;j++) { "<button onclick='remove_me(this)' id="+list_array[j]+">Remove</button><br>"; } } function remove_me(obj) { _button = obj.id; remove(_button); } I am trying to perform this operation, however, it only receive "Product" in obj.id.............It skips the text after the first whitespace..... I hope that you got my concern, looking for quick reply.......
  10. Hi guys, I have a relatively hard question. The problem is that I must leave the HTML code as it is and not put any divs around the image tags. How can I add a class or a selector to an image tag so that I can style that specific image tag for a specific style sheet. The reason why I'm doing this is because my code is styled in three different style sheets for responsive web design. I need a way to select these image tags using an identifier without affect the html code to go crazy in other layouts. <img src="./ajaxfiles/globebuttons/1xtremevision.png" alt="" name="btn3" id="btn3" onclick="MM_swapImage('car','','./ajaxfiles/carbackgrounds/XtremeVision-E-City.jpg','btn1','','./ajaxfiles/globebuttons/1standardreplacement.png','btn2','','./ajaxfiles/globebuttons/1powervision.png','btn3','','./ajaxfiles/globebuttons/xtremevision.png','btn4','','./ajaxfiles/globebuttons/1bluevisionultra.png','btn5','','./ajaxfiles/globebuttons/1crystalvision.png','btn6','','./ajaxfiles/globebuttons/1diamondvision.png',1)" /> Any help would be much appreciated, please post a way to style these image tags ? All the best, Adam
  11. i have resposive webpage layout with masonry. when user resizes the browser below certain viewport width, i destroy masonry. but after user resized back, i can't reinitialize masonry. it just will not arrange the blocks as it should. any ideas how to fix this?
  12. Hi guys, I'm trying to build the following functionality, but find myself seriously lacking in coding aptitude and knowledge. I'm hoping you guys can help me out. Ultimate goal: Clean search bar in middle of screen with no submit button; typing specific text ex. "test" brings an html/javascript widget from a separate file ex. "test1.html" and includes that content below the search bar all without a refresh. My current solution (and note that the code is retrofitted from a different project that someone else wrote), is an if-then solution, whereby if the text in the input == "test" then the page includes the test1.html file. main.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Testing</title> <script language="javascript" type="text/javascript"> var XMLHttpRequestObject_test = false; var strSend; if (window.XMLHttpRequest) { XMLHttpRequestObject_test = new XMLHttpRequest(); } else if (window.ActiveXObject) { XMLHttpRequestObject_test = new ActiveXObject("Microsoft.XMLHTTP"); } var i; var finished; function test() { if (XMLHttpRequestObject_test) { strSend = "receive.php?"; i = 0; finished = false; while (finished != true) { if (document.input1.elements[i].type == "text") { strSend = strSend + "&" + document.input1.elements[i].name + "=" + document.input1.elements[i].value; } else if (document.input1.elements[i].type == "checkbox") { strSend = strSend + "&" + document.input1.elements[i].name + "=" + document.input1.elements[i].checked; } else if (document.input1.elements[i].type == "hidden") { strSend = strSend + "&" + document.input1.elements[i].name + "=" + document.input1.elements[i].value; } else if (document.input1.elements[i].type == "password") { strSend = strSend + "&" + document.input1.elements[i].name + "=" + document.input1.elements[i].value; } i = i + 1; if (document.input1.elements[i] != "[object HTMLInputElement]") { finished = true; } else { finished = false; } } XMLHttpRequestObject_test.open("GET", strSend); XMLHttpRequestObject_test.onreadystatechange = function () { if (XMLHttpRequestObject_test.readyState == 4 && XMLHttpRequestObject_test.status == 200) { document.getElementById('test').innerHTML = XMLHttpRequestObject_test.responseText; } } XMLHttpRequestObject_test.send(null); } } </script> </head> <body> <form name="input1"> <input name="txt1" type="text" /> </form><br /> <input name="cmd_submit" type="button" value="Submit" onclick="test()" /><br/> <br/> <div id="test"></div> </body> </html> receive.php <?php if($_REQUEST['txt1'] == "test") { include('test1.html'); } else { echo stripslashes($_REQUEST['txt1']); } ?> Test1.html (the content to be included) <?php echo '<script type="text/javascript" src="http://www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/100840413740199312943/stock-quotes.xml&up_stockList=%5EIXIC%2C%5EGSPC%2C%5EN225%2C%5EHSI%2C%5ESTI%2C%5EFTSE%2C%5EGDAXI%2C%5EFCHI&up_chart_bool=1&up_font_size=12&up_symbol_bool=0&up_chart_period=0&up_refresh_secs=30&synd=open&w=290&h=300&title=Stock+Quotes&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>'; echo '<p class="p1">ONETEST!</p>'; ?> Result after typing "test" into search bar (no quotes) [SEARCH BAR] ONETEST! Very accurate representation of the search bar, I know. But the google widget that I used to test this doesn't show up, only the text. I have tried many variations on trying to echo the javascript such that php doesn't chuck it, but nothing. // I have alternative code that includes the content via ajax without the use of php and it brings the widget in without a problem, however, I have no idea how to make that "search bar - if string == 'test', then, show include" paradigm without php. Thank you in advance, Alex Long time visitor, first time poster
  13. </html> <script type="text/javascript"> var inc = 10; function move_down() { bar = document.getElementById('tarea'); inc += 10; bar.scrollTop = inc; document.getElementById("write").innerHTML = inc; } function move_up() { bar = document.getElementById('tarea'); inc -= 10; bar.scrollTop = inc; document.getElementById("write").innerHTML = inc; } setInterval( function() { if(inc>=450) {move_up();} if(inc<450) {move_down();} } ,100); </script> <body> This is a code that will help in running data in the same loation, vertically <br> <br> <textarea rows="10" cols="20" id="tarea"> this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text this is a text </textarea> <br><br> <button onclick="movedown()" id="tarea">Click here</button><br> <div id="write"></div> </body> </html> I am trying to make a auto scroll function in java script, however, I am unable to do it, can you help with the code and tell what is wrong with the code ....................
  14. I am trying to code something in Java-script, I am trying to "fade_in" image and "fade_out" image with Set_interval function, I am facing problem, help me @@@@@ <html> <script type="text/javascript"> var inc_bit =1e-2; function inc_change() { var s = document.getElementById('img'); document.getElementById('write').innerHTML = inc_bit; inc_bit = inc_bit + 1e-2; s.style.opacity = inc_bit; if(inc_bit>1e0) { setInterval(function() {dec_change();},100); } } function dec_change() { var s = document.getElementById('img'); document.getElementById('write').innerHTML = inc_bit; inc_bit = inc_bit - 1e-2; s.style.opacity = inc_bit; if(inc_bit<1e-2) { setInterval(function() {inc_change();},100); } } setInterval(function() {inc_change();},90); </script> <body onload="inc_change()"> <img src="pic1.jpg" height="200px" width="250px" id="img" style="opacity:0.0"/> <div id='write'></div> </body> </html>
  15. An invoice will be opened in a new window when the Generate invoice button is clicked. Below is the sample code. For Example <form name="invoice" action="inv_rec.php" method="post" id="inv" target="invoices" onsubmit="return check_counter();" > <table> <tr> <td> <label for="cusname"><strong>Customer Name* </strong></label> <input type="text" size="20" name ="cusname" value="" id="Customername" required/> </td> <td> <label for="for_place"><strong>Place</strong></label> <input type="text" size="20" name ="for_place" value="" id="for_place" /> </td> </tr> ........ <tr> <td> <input type="submit" value="Generate Invoice" name="submit" id="sub"> </td> </tr> </table> </form> <script> var counter = 1; function check_counter() { if(counter == 1) { alert("Please enter the product details"); return false; } window.open('', 'invoices', 'width=650,height=800,status=yes,resizable=yes,scrollbars=yes'); return true; } </script> In my example the page will be redirected to inv_rec.php(opens in new window) which contains dynamically generated data obtained from mysql where the user needs to take the print of it. I want to clear all the form data which is open in the previous window(where the invoice form is displayed,i.e user fills the data to generate a invoice).Any help is appreciated.
  16. I need some help amending a comment tag in a text-area. Of-course this would be easy if I could just simply edit the html. However the script is using an i-frame. I can't find where the i-frame code is. What can I do when looking in the directory for the iframe, where is it? If you need me to show you the file structure that can be done and I can show you the code of where the iframe is.
  17. Hi all, I have a webpage which opens redeem.html. The page has an option which you can see in the URL given underneath. - Caltex starcash card promotion When clicking on the navigation bar "redeem" its opens redeem.html however I'd like it to select the first option "Caltex starcash car promotion" by default on click of redeem in the navigation bar. So at first the url looks like this: http://www.continentalpromotions.com.au/redeem.html and I want this : http://www.continentalpromotions.com.au/redeem.html# Click on the url and have a go at looking at the URL to understand what I want, I can't figure this one out right now on how to get the options to be selected already. Any help would be very much appreciated the code is listed underneath of the <div> containing the link. <div class="span4"><a href="#"><img id="promo1" src="img/Promotions/redeempage/CaltexCardredeem.png" onClick="changeimage()" width="284" height="261" border="0"></a><br> <br> </div>
  18. Hello everyone! I'll get straight to the point. I have built a portfolio gallery for a client that uses a javascript/jquery to arrange my thumbnails on a single page. It includes a "filter" function that allows me to narrow down what is displayed on the page based on certain keywords associated with the content. I have an upload script which allows me to add data through a form to my MySQL database. The image name is saved to the database and the image is uploaded to a particular folder on my server. I then pull that information into my portfolio page and loop through all the "rows" in the database which creates my page full of thumbnails. When a user clicks on any given thumbnail, a lightbox is shown which shows a larger image or embedded video, along with the title and description of the project. Everything works great. I would like to go one step further and add a feature to click to the "next" and "previous" item in the portfolio from within the lightbox without having to close the lightbox and click another thumbnail. Make sense? I am a beginner with php but am learning my way around it. Javascript is still a foreign language so I would like to accomplish this in PHP if possible. Thank you for any help you can offer to get me in the right direction. <?php include('includes/connection.php'); $tbl_name="portfolio_pg"; ?> <nav id="filter"></nav> <section id="main"> <ul id="grid"> <?php $data = mysql_query("SELECT * FROM portfolio_pg") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { ?> <li data-tags="<?php echo $info['Filters']; ?>"> <a href="javascript:void();" onclick="document.getElementById('underlay').style.display='block'; document.getElementById('<?php echo $info['pg_id']; ?>').style.display='block';"><?php echo "<img src=images/portfolio/thumbs/".$info['photo'] ." width=\"164\" height=\"164\">"; ?></a> <div id="underlay"></div> <div class="lightbox" id="<?php echo $info['pg_id']; ?>"> <div id="closer"><a href="javascript:void();" onclick="document.getElementById('underlay').style.display='none'; document.getElementById('<?php echo $info['pg_id']; ?>').style.display='none';">close</a></div> <?php if($info['Project_Link']!="") { echo "<div class=\"vidHolder\"> ".$info['Project_Link']." </div>"; } else { echo "<div class=\"picHolder\"><img src=\"images/portfolio/".$info['photo_2'] ."\" width=\"100%\" height=\"100%\"></div>"; } ?> <div class="projectHead"><?php echo $info['Page_Heading_1']; ?></div> <div class="projectBod"><?php echo $info['Paragraph_1']; ?></div> </div><!-- Close Lightbox Viewer --> </li> <?php // close while loop } ?> </ul> </section> you can see it in action by going following HERE Thanks for any help
  19. I am working on code that can run images from left to right when I click on hyperlink ?? The code is listed below, please help me out ... <script type="text/javascript"> var left3; function next1() { var str = document.getElementById('pic01'); var left2 = parseInt(str.offsetLeft); left3 = left2; } function next2() { left3 =left3 + 50; var st = left3+'px'; document.getElementById('pic01').offsetLeft=st; } </script> <body onLoad="next1()"> <img src="pic1.jpg" height="100px" width="120px" style="margin-left:125px;" id="pic01"/> <br><br> <a href="#" style="margin-left:100px" onClick="next2()">Next</a> <body>
  20. Hello, I have piece of code I have written that, when the form is submitted it sends the string from the textbox through ajax, through a database and returns a name corresponding to that string. It works fine in chrome but not in firefox and I was wondering if you could help. If I set the function to a simple alert(code) it will fire it and work fine however when I revert it to the ajax script it simply reloads the page with the "?code=string" and ignores anything and everything in the js function. This is the ajax code: function signin(code) { // event.preventDefault(); var xmlhttp; var photo; if (code=="") { document.getElementById("resultcontents").innerHTML="lol"; return; } 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) { var str = xmlhttp.responseText; var split = str.split(", "); document.getElementById("resultcontents").innerHTML=split['0']; document.getElementById("counter").innerHTML=split['1']; if(!(split['2'] == undefined)){ document.getElementById("webcamcanvas").innerHTML="<img src='" +split['2']+"' width='400' height='300'>"; } document.getElementById("codetextbox").value=""; document.getElementById("codetextbox").focus(); } } xmlhttp.open("GET","files/******.php?code="+code,true); xmlhttp.send(); } This is the HTML form: form onsubmit="signin(codeform.codetextbox.value)" name="codeform"> <input type="textbox" name="codetextbox" id="codetextbox" /> </form> The reason it has no submit button is because firstly, it clutters up the page and secondly I'm using a barcode scanner which automatically inserts a carriage return, submitting the form. Any help would be greatly appreciated! Also, I'm sorry if this is in the wrong section, it's to do with both JS and Ajax and I didn't know which to choose. Jacbey.
  21. Though I think it is not a PHP related question but as the website I am working on is developed in PHP so, I thought I may get answer to it from here. The website I am working on is a Property Search kind of website and it uses MLS System for the list of properties. The basic essence is to select a Property and add it to a Magazine. And when the Magazine is filled up with specific # of properties then make a PDF format magazine of all properties. Now, I know about FPDF and I have used it also... There is TCPDF also... but all of them just grab data and automatically creates PDF document. I want the admin of site to manually create a PDF from all the list of properties by using mouse. Like drag and drop scenario. I know it is not a PHP thing... because PHP runs on the server. But if someone knows of any library, tool, or framework in PHP or in JavaScript... or if I can use HTML5 in any manner... then please let me know! The task at hand is very important and I don't have much time to finish it. Any kind of help would be much appreciated! Regards!
  22. Hey guys i have a general question not sure if this is the right place to post it but im going to go ahead and ask. I'm looking to design my own media player that can be embedded in other pages. Problem is i cant seem to figure out how to start. Could someone point me in the right direction? I'm assuming JavaScript is the language i should try doing this with but not sure! any Input is appreciated. would be an audio player.
  23. i have two text boxes in my form.when i type the text in the first text box which is English language.now i need to display the the text in Telugu language in other text box. Please let me know how can i do this in php.
  24. I am currently working off of a Wordpress template from Gavick. Here is the website: earthcharterfest.com/wordpress Within the homepage of the site, there is a widget that displays five circular containers under the header "Venues". The containers hold images that move one by one from the right to the left every few seconds or so. The content within the containers is determined by Wordpress "posts" within the Widget. So for every post I create, a new container is also created. What I would like to do is, instead of having the containers move left to right one by one, to make them move five containers at a time. This way I can have images all related to a single venue, and have other sets of images for various venues. I was told that in order to do this that these files must be edited: /wp-content/themes/Fest/gavern/widget.speakers.php is the file that generates content, /wp-content/themes/Fest/js/widgets/speakers.js is a jQuery file that creates animation. However, I have very little experience with both Javascript and PHP. Can anyone be of assistance? Below are the two files that deal with the Circular Container Widget. Gavick calls this widget the Speakers Widget. Website: earthcharterfest.com/wordpress /wp-content/themes/Fest/js/widgets/speakers.js: // // GK Speakers Widget // jQuery(window).load(function(){ jQuery(document).find('.widget_gk_speakers').each(function(i, widget) { new GK_Speakers(jQuery(widget)); }); }); function GK_Speakers(widget) { this.$G = null; this.current_offset = 0; this.anim_interval = 0; this.current = 0; this.total = 0; this.items = []; this.availableItems = null; this.hover = false; this.$G = { 'animation_speed': 500, 'animation_interval': 5000, }; this.current_offset = 0; this.anim_interval = this.$G['animation_interval']; this.current = 4; this.total = widget.find('.gkw-rest-speakers .gkw-speaker').length; // if there is more than 5 slides if(this.total > 5) { // prepare handlers this.items[0] = widget.find('.gkw-speakers-small-left .gkw-speaker-small').first(); this.items[1] = widget.find('.gkw-speakers-small-left .gkw-speaker-small').first().next(); this.items[2] = widget.find('.gkw-speakers .gkw-speaker-big').first(); this.items[3] = widget.find('.gkw-speakers-small-right .gkw-speaker-small').first(); this.items[4] = widget.find('.gkw-speakers-small-right .gkw-speaker-small').first().next(); // this.availableItems = widget.find('.gkw-rest-speakers .gkw-speaker'); // var $this = this; // jQuery(this.items).each(function(i, el) { jQuery(el).removeClass('speaker-hide'); }); // run the animation setTimeout(function() { $this.gkChangeSpeakers(); }, this.anim_interval + 400); jQuery(this.items).each(function(i, el) { jQuery(el).mouseenter(function() { $this.hover = true; }); jQuery(el).mouseleave(function() { $this.hover = false; }); }); } } GK_Speakers.prototype.gkChangeSpeakers = function() { // var $this = this; // if(!this.hover) { // hide speakers jQuery(this.items).each(function(i, el) { jQuery(el).addClass('speaker-hide'); }); if(this.current < this.total - 1) { this.current += 1; } else { this.current = 0; } setTimeout(function() { var IDs = [0, 0, 0, 0, 0]; IDs[4] = $this.current; totalOffset = $this.total; IDs[3] = ($this.current - 1 < 0) ? --totalOffset : $this.current - 1; IDs[2] = ($this.current - 2 < 0) ? --totalOffset : $this.current - 2; IDs[1] = ($this.current - 3 < 0) ? --totalOffset : $this.current - 3; IDs[0] = ($this.current - 4 < 0) ? --totalOffset : $this.current - 4; jQuery($this.items[0]).html(jQuery($this.availableItems[IDs[0]]).html()); jQuery($this.items[1]).html(jQuery($this.availableItems[IDs[1]]).html()); jQuery($this.items[2]).html(jQuery($this.availableItems[IDs[2]]).html()); jQuery($this.items[3]).html(jQuery($this.availableItems[IDs[3]]).html()); jQuery($this.items[4]).html(jQuery($this.availableItems[IDs[4]]).html()); }, 600); // show speakers setTimeout(function() { jQuery($this.items).each(function(i, el) { jQuery(el).removeClass('speaker-hide'); }); }, 750); } // setTimeout(function() { $this.gkChangeSpeakers(); }, this.anim_interval + 800); }; /wp-content/themes/Fest/gavern/widget.speakers.php: <?php /** * * GK Speakers Widget class * **/ class GK_Speakers_Widget extends WP_Widget { /** * * Constructor * * @return void * **/ function GK_Speakers_Widget() { $this->WP_Widget( 'widget_gk_speakers', __( 'GK Speakers', GKTPLNAME ), array( 'classname' => 'widget_gk_speakers', 'description' => __( 'Use this widget to show rotator with speakers', GKTPLNAME) ) ); $this->alt_option_name = 'widget_gk_speakers'; add_action( 'save_post', array(&$this, 'refresh_cache' ) ); add_action( 'delete_post', array(&$this, 'refresh_cache' ) ); add_action('wp_enqueue_scripts', array('GK_Speakers_Widget', 'add_scripts')); } static function add_scripts() { wp_register_script( 'gk-speakers', get_template_directory_uri() . '/js/widgets/speakers.js', array('jquery')); wp_enqueue_script('gk-speakers'); } /** * * Outputs the HTML code of this widget. * * @param array An array of standard parameters for widgets in this theme * @param array An array of settings for this widget instance * @return void * **/ function widget($args, $instance) { $cache = get_transient(md5($this->id)); // the part with the title and widget wrappers cannot be cached! // in order to avoid problems with the calculating columns // extract($args, EXTR_SKIP); $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Speakers', GKTPLNAME ) : $instance['title'], $instance, $this->id_base); echo $before_widget; echo $before_title; echo $title; echo $after_title; if($cache) { echo $cache; echo $after_widget; return; } ob_start(); // $category = empty($instance['category']) ? '' : $instance['category']; $anim_speed = empty($instance['anim_speed']) ? 500 : $instance['anim_speed']; $anim_interval = empty($instance['anim_interval']) ? 5000 : $instance['anim_interval']; // $gk_loop = new WP_Query( 'category_name=' . $category . '&post_type=gavern_speakers'); $speakers = array(); while($gk_loop->have_posts()) { $gk_loop->the_post(); array_push($speakers, array( 'title' => get_the_title(), 'img' => wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) ), 'url' => get_permalink() )); } wp_reset_postdata(); if (count($speakers)) { if(count($speakers) >= 5) { echo '<div class="gkw-speakers"> <div class="gkw-speaker-big speaker-hide"> <div> <a href="'.$speakers[2]['url'].'"> <img src="'.$speakers[2]['img'].'" alt="'.$speakers[2]['title'].'" /> </a> </div> <h4> <a href="'.$speakers[2]['url'].'" title="'.$speakers[2]['title'].'">'.$speakers[2]['title'].'</a> </h4> </div> <div class="gkw-speakers-small-left"> <div class="gkw-speaker-small speaker-hide"> <div> <a href="'.$speakers[0]['url'].'"> <img src="'.$speakers[0]['img'].'" alt="'.$speakers[0]['title'].'" /> </a> </div> <h4> <a href="'.$speakers[0]['url'].'" title="'.$speakers[0]['title'].'">'.$speakers[0]['title'].'</a> </h4> </div> <div class="gkw-speaker-small speaker-hide"> <div> <a href="'.$speakers[1]['url'].'"> <img src="'.$speakers[1]['img'].'" alt="'.$speakers[1]['title'].'" /> </a> </div> <h4> <a href="'.$speakers[1]['url'].'" title="'.$speakers[1]['title'].'">'.$speakers[1]['title'].'</a> </h4> </div> </div> <div class="gkw-speakers-small-right"> <div class="gkw-speaker-small speaker-hide"> <div> <a href="'.$speakers[3]['url'].'"> <img src="'.$speakers[3]['img'].'" alt="'.$speakers[3]['title'].'" /> </a> </div> <h4> <a href="'.$speakers[3]['url'].'" title="'.$speakers[3]['title'].'">'.$speakers[3]['title'].'</a> </h4> </div> <div class="gkw-speaker-small speaker-hide"> <div> <a href="'.$speakers[4]['url'].'"> <img src="'.$speakers[4]['img'].'" alt="'.$speakers[4]['title'].'" /> </a> </div> <h4> <a href="'.$speakers[4]['url'].'" title="'.$speakers[4]['title'].'">'.$speakers[4]['title'].'</a> </h4> </div> </div> </div> <div class="gkw-rest-speakers">'; for($i = 0; $i < count($speakers); $i++) { echo '<div class="gkw-speaker"> <div> <a href="'.$speakers[$i]['url'].'"> <img src="'.$speakers[$i]['img'].'" alt="'.$speakers[$i]['title'].'" /> </a> </div> <h4> <a href="'.$speakers[$i]['url'].'" title="'.$speakers[$i]['title'].'">'.$speakers[$i]['title'].'</a> </h4> </div>'; } echo '</div>'; } } // save the cache results $cache_output = ob_get_flush(); set_transient(md5($this->id) , $cache_output, 3 * 60 * 60); // echo $after_widget; } /** * * Used in the back-end to update the module options * * @param array new instance of the widget settings * @param array old instance of the widget settings * @return updated instance of the widget settings * **/ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['category'] = strip_tags( $new_instance['category'] ); $instance['anim_speed'] = strip_tags( $new_instance['anim_speed'] ); $instance['anim_interval'] = strip_tags( $new_instance['anim_interval'] ); $this->refresh_cache(); $alloptions = wp_cache_get('alloptions', 'options'); if(isset($alloptions['widget_gk_speakers'])) { delete_option( 'widget_gk_speakers' ); } return $instance; } /** * * Refreshes the widget cache data * * @return void * **/ function refresh_cache() { delete_transient(md5($this->id)); } /** * * Limits the comment text to specified words amount * * @param string input text * @param int amount of words * @return string the cutted text * **/ function comment_text($input, $amount = 20) { $output = ''; $input = strip_tags($input); $input = explode(' ', $input); for($i = 0; $i < $amount; $i++) { $output .= $input[$i] . ' '; } return $output; } /** * * Outputs the HTML code of the widget in the back-end * * @param array instance of the widget settings * @return void - HTML output * **/ function form($instance) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $category = isset($instance['category']) ? esc_attr($instance['category']) : ''; $anim_speed = isset($instance['anim_speed']) ? esc_attr($instance['anim_speed']) : ''; $anim_interval = isset($instance['anim_interval']) ? esc_attr($instance['anim_interval']) : ''; ?> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', GKTPLNAME ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> </p> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php _e( 'Category slug:', GKTPLNAME ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>" type="text" value="<?php echo esc_attr( $category ); ?>" /> </p> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'anim_speed' ) ); ?>"><?php _e( 'Animation speed (in ms):', GKTPLNAME ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'anim_speed' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'anim_speed' ) ); ?>" type="text" value="<?php echo esc_attr( $anim_speed ); ?>" /> </p> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'anim_interval' ) ); ?>"><?php _e( 'Animation interval (in ms):', GKTPLNAME ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'anim_interval' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'anim_interval' ) ); ?>" type="text" value="<?php echo esc_attr( $anim_interval ); ?>" /> </p> <?php } } // EOF
  25. Hi, I'm trying to make some kind of validation for my form but I've tried everything from Javascript to PHP and I can't seem to get it to work? I'll put my javascript code below but I would much rather use PHP as the validator as I don't like using alert boxes. The problem is that it's validating at all and any method that I try it just skips it and carrys on with the registration. For example I put "dd" as my username, email and password and it accepted it. Help would be much appreciated, thanks. The Javascript: <script type="text/javascript"> function validateForm(formElement) { if(formElement.username.length < 5) { alert('Username must be more than 5 characters.'); return false; } if(formElement.email.length < 5) { alert('Email must be more than 5 characters.'); return false; } if(formElement.password.length < { alert('Password should be more than 8 characters.'); return false; } } </script> The Form: <div id="register-section-wrapper"> <div id="inner-register-container"> <form action="" method="post" name="register_form" id="register_form" onsubmit="return validateForm(this);"> <table border="0" id="table-register"> <th colspan="2"> <h1>Register</h1> </th> <tr> <td> <p>Username:</p> </td> <td> <input type="text" name="username" id="username" class="frm-style" required /> </td> </tr> <tr> <td> <p>Email:</p> </td> <td> <input type="text" name="email" id="email" class="frm-style" required /> </td> </tr> <tr> <td> <p>Password:</p> </td> <td> <input type="password" name="password"id="password" class="frm-style" required /> </td> </tr> <tr> <td> <p>Retype Password:</p> </td> <td> <input type="password" name="cpassword" class="frm-style" required /> </td> </tr> <tr> <th colspan="2"> <input class="frm-submit-register" name="register" type="submit" value="Submit" onclick="return validateForm(this.form);" /> <th> </tr> </table> </form> The OLD PHP Validation: <?php $error_msg = ""; if(isset($_POST['register'])) { if(empty($_POST['username'])) { $error_msg = "Please enter your username."; } else { return true; } if($_POST['username'] < 5) { $error_msg = "Username must be more than 5 characters."; } else { return true; } } ?>
×
×
  • 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.