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. Hello, I've just started learning PHP, JavaScript and I've got a big problem on my website. I'm getting this ReferenceError. I know what's the problem, but I don't know how to solve it, and I know people can do it for money but I don't have money, I'm searching for someone who's willing to help newbie. As I said I'm begginer, and I know something. The main problem is because I want to use GKPlugin and Player(jwplayer). Plugin need to use object, example: <object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400"> <param name="movie" value="player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" /> <embed name="flashplayer" src="player.swf" FlashVars="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" /> </object> Script is generetad just to embed with iframe, and the problem is when I replace it with object, then I'm getting this error. I know that JS can't "call" that iframe to show because I've replaced it with object. You guys probably know about what I'm talking. I'm just searching for some instructions, guidelines from you. ReferenceError: embeds is not defined if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){ Here's the rest of code, I think it's used to show iframe. elseif (substr_count($link,"gorillavid")){ $video_id = explode("/",$link); if (isset($video_id[count($video_id)-1])){ $video_id = $video_id[count($video_id)-1]; $embed = '<object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400"> <param name="movie" value="http://www.kiinc.com/videott/player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" /> <embed name="flashplayer" src="player.swf" FlashVars="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" /> </object>'; This is the original code. Don't look at providers(source as gorillavid) because I used gorillavid in previous an posted another example from another source (zalaa) elseif (substr_count($link,"zalaa")){ $video_id = explode("/",$link); if (isset($video_id[count($video_id)-1])){ $video_id = $video_id[count($video_id)-1]; $embed = '<IFRAME SRC="http://www.zalaa.com/embed-'.$video_id.'.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH='.$width.' HEIGHT='.$height.'></IFRAME>'; Function which embed links and should embed GKPlugin/Player: // general image link if (!$embed){ $embed = "<div style='background-color:#000000; width: ".$width."px; height: ".$height."px;text-align:center;cursor:pointer;' onclick='window.open(\"$link\");'>"; $embed.= "<p style='text-align:center; padding-top: 70px;'>"; $embed.= "<a href='$link' target='_blank' style='font-size:24px; color: #ffffff !important'>Click here to play this video</a>"; $embed.= "</p>"; $embed.= "</div>"; } return $embed; } JavaScript code: function getEmbed(embedid){ if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){ var html_content = "<div class='fake_embed' id='fake_embed"+embedid+"' onclick='closeFakeEmbed("+embedid+");'>" + "<br /><br />" + "<div class='fake_embed_ad_close'><a href='javascript:void(0);' onclick='closeFakeEmbed("+embedid+");'>Close Ad</a></div>" + "<div class='fake_embed_ad' id='fake_embed_ad" + embedid +"'>" + "<iframe src='"+baseurl+"/iframe_ad.php' width='300' height='300' frameborder='NO' border='0'></iframe>" + "</div>" + "<div class='fake_embed_bar'><span class='fake_embed_bar_right'></span></div>" + "</div>" + "<div id='real_embed"+embedid+"' style='display:none'>"+embeds[embedid]+"</div>"; jQuery('#videoBox'+embedid).html(html_content); jQuery('#videoBox'+embedid).show(); } else { jQuery('#videoBox'+embedid).html(embeds[embedid]); jQuery('#videoBox'+embedid).show(); } } function countDown(embedid){ showCounter = showCounter-1; jQuery('span#counter').html(showCounter); if (showCounter>0){ showTimer = setTimeout('countDown('+embedid+');',1000); } else { showTimer = null; showCounter = 20; getEmbed(embedid); } } function changeEmbed(embedid, counter){ if (counter == 0){ jQuery('.embedcontainer').html(''); jQuery('.embedcontainer').hide(); getEmbed(embedid); } else { if (showTimer){ clearTimeout(showTimer); } showTimer = null; showCounter = counter; jQuery('.embedcontainer').html(''); jQuery('.embedcontainer').hide(); jQuery('#videoBox'+embedid).html(js_lang.ticker); jQuery('#videoBox'+embedid+' span#counter').html(showCounter); jQuery('#videoBox'+embedid).slideDown("slow"); showTimer = setTimeout('countDown('+embedid+');',1000); } /* jQuery('li.selected').removeClass('selected'); jQuery('#selector'+embedid).addClass('selected'); */ }
  2. I have been coding for past 2 month with php , like login script ect. I wana know how and what must one do to become better at php , in order to get into job market for example. What books or videos do you recommend? im using mysqli as a beginner of course. but many times i feel so lost with php when i get an error. HOW to avoid this? How can i understand this language better? How do you before you code, draw out ur plans on what u going to do for the project and how u will structure if ps i dont know a super lot about php jargon thanks guy would like to know erveryones thoughts
  3. Hello, Here is my current code: index.php <html> <body> <form id="hey" name="hey" method="post" onsubmit="return false"> Name:<input type="text" name="name"> <input type="submit" name="submit" value="click"> </form> <table class="table table-bordered" id="update"> <thead> <th>Name</th> </thead> <tbody> <script type="text/javascript"> $("#hey").submit(function() { $.ajax({ type: 'GET', url: 'response.php', data: { username: $('#name').val()}, success: function (data) { $("#update").prepend(data); }, error: function (xhr, ajaxOptions, thrownError) { alert(thrownError); } }); }); </script> </tbody> </table> response.php <?php $username = $_GET['username']; echo "<tr>"; echo "<td>$username</td>"; echo "</tr>"; ?> This code works fine, it prints out the rows as what the user enters. Now what I want to do is, log all these entries to a mySQL database and also, display these rows over the site. i.e., any user who is online, should be seeing this without having to refresh the page too.. Real time updates in a way. How can I achieve that? Thanks!
  4. so I am not the best coder, and have been having a really hard time getting this devision in javascript. I would put it in html, but I use javascript to clear the page <div id="test" style='position:fixed;bottom:0;left:0; height:76;background:darkorange;width:100%;'><h><object width="75" onclick="web()" height="75" data="img1.jpg"></object> <object width="75" onclick="mdoge()" height="75" data="img2.jpg"></object> <object width="75" onclick="word()" height="75" data="img3.jpg"></object></h></div> so that code above is the code I need to put in a document.write of something of equivalence. Is there any way to put this in javascript? thank you
  5. I want when onmouseover on particular section to put an OPACITY #fff 0.2 layer on everything except the selected class i.e. table Similarly as you have: .tableHighlight:hover{background-color:#eee} <table id='table-main' class='tableHighlight'> ... but inversed (puts layer on everything else, but not the table itself) --- http://jsfiddle.net/LYcm9/1/
  6. http://paste.ee/p/OhiWv The above is a link to a readable version of my code. The XMLHTTPREQUEST worked, and the array was pulled down. Was able to print out the undecoded/unparsed array. However, immediately afterwards, all code stops working. <script> var xhr; if (window.XMLHttpRequest) { // Mozilla, Safari, ... xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE 8 and older xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("POST", "PHPLibrary/selectMemberResults.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(); xhr.onreadystatechange = display_data; var $phparray function display_data() { if (xhr.readyState == 4) { if (xhr.status == 200) { //alert(xhr.responseText); $phparray = xhr.responseText; document.getElementById("suggestion").innerHTML = $phparray; // // //......................................................? // The above line of code is the last thing to print or // to do anything that returns to the browser.... //.......................................................? // All lines below do nothing............................? // } else { //alert('There was a problem with the request.'); } } } document.write("Length of phparray Array :" + $phparray.length + "<"); var output = JSON.parse($phparray, function (key,val) { if ( typeof val === 'string' ) { // regular expression to remove extra white space if ( val.indexOf('\n') !== -1 ) { var re = /\s\s+/g; return val.replace(re, ' '); } else { return val; } } return val; } ); document.write("Length of Array :" + $output.length + "<"); for (var i=0; i < $output.length; i++) { document.getElementById("suggestion").innerHTML = $output[i].MEMBER_NAME; } </script>
  7. Here is my add driver button $( "#addDriver" ).button().click(function( event ) { event.preventDefault(); var dn = $("input[name=driver_name]").val(); var ds = $("input[name=driver_status]").val(); var dataString = 'driver_name='+ dn + '&driver_status='+ ds; //Here is where im trying to load it but it's not working $('#driversTable').jtable('load'); if(dn == '' || ds == '' ) { alert("Fill up all Fields with \'*\'"); } else { $.ajax({ type: "POST", url: "processDriver.php", data: dataString, dataType: "json", success: function(data){ if(!data.error && data.success) { alert(data.successMsg); $("input[name=driver_name]").val(''); $("input[name=driver_status]").val(''); } else { alert(data.errorMsg); } } }); } }); And here is my jTable init $("#driversTable").jtable({ title: 'Drivers', actions: { listAction: "getAllDrivers.php", }, fields: { did: { key: true, list: false }, dID: { title: 'Driver ID', width: '7%' }, dName: { title: 'Name', width: '7%' }, dStatus: { title: 'Status', width: '12%' } } }); $('#driversTable').jtable('load'); I want it to be right after adding a new record i want the table to refresh without refreshing the page. I tried the load and reload functions of jtable is not working or am i just putting them on the wrong place of my code?
  8. Hello Php Friends, I have this search code, it wents well but i want to add and echo or maybe a script that woul tell "NO RESULTS FOUND" in case the search does not found data in the database. Please anyone can help. include 'Connect.php'; //Connect to MySQL Server mysql_connect($host, $dbusername, $dbpassword); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query $first_name = $_GET['first_name']; // Escape User Input to help prevent SQL Injection $first_name = mysql_real_escape_string($first_name); $query = "SELECT * FROM student_information WHERE first_name = '$first_name'"; $qry_result = mysql_query($query) or die(mysql_error()); $display_string = "<table border='1' cellpadding='10' cellspacing='1' align='center'>"; $display_string .= "<tr align='center'>"; $display_string .= "<th>LR Number</th>"; $display_string .= "<th>F i r s t N a m e</th>"; $display_string .= "<th>L a s t N a m e</th>"; $display_string .= "<th>Grade</th>"; $display_string .= "<th>Section</th>"; $display_string .= "<th>View</th>"; $display_string .= "<th>Update</th>"; $display_string .= "<th>Delete</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$row[LRN]</td>"; $display_string .= "<td>$row[first_name]</td>"; $display_string .= "<td>$row[last_name]</td>"; $display_string .= "<td>$row[grade]</td>"; $display_string .= "<td>$row[section]</td>"; $display_string .= "<td><a href='View_Profile.php?id=$student_id'>View</a> </td>"; $display_string .= "<td><a href='Admin_Edit_Student_Info.php?id=$student_id'>Update</a></td>"; $display_string .= "<td><a href='Delete.php?id=$student_id'>Delete</a></td>"; } $display_string .= "</table>"; echo $display_string; ?> Kindly tell me what codes i am missing and where exactly to put it.
  9. I have this function call I want tied directly into a var: startTone( tone ); How would I tie it into a var similar to how I have this var created: audio = new Audio(); audio.src = "sound.mp3"; audio.loop = false; audio.play();
  10. I have a script that allows me to post comments, but when i try to delete that comment i get a error message telling me that a specific variable is undefined. I refresh the page and try again, and suddently it works. template_test.php <?php if($author == $log_username || $account_name == $log_username ){ $statusDeleteButton = '<span id="sdb_'.$statusid.'"><a href="#" onclick="return false;" onmousedown="deleteStatus(\''.$statusid.'\',\'status_'.$statusid.'\',\''.$DB_table.'\');" title="DELETE THIS STATUS AND ITS REPLIES">delete status</a></span> '; } ?> <script> function deleteStatus(statusid,statusbox,document){ var ajax = ajaxObj("POST", "php_parsers/status_system2.php"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) === true) { if(ajax.responseText === "delete_ok"){ // remove the div all of the tekst is inside, the textarea and the reply button _(statusbox).style.display = 'none'; _("replytext_"+statusid).style.display = 'none'; _("replyBtn_"+statusid).style.display = 'none'; } else { alert(ajax.responseText); } } } ajax.send("action=delete_status&statusid="+statusid+"&document="+document); }; </script> php_parsers/status_system2.php <?php // fires of when the someone deletes a thread if (isset($_POST['action']) && $_POST['action'] == "delete_status" && !empty($_POST['document'])){ if(!isset($_POST['statusid']) || $_POST['statusid'] == ""){ echo "status id is missing"; exit(); } // sanitize the inserted status id $statusid = preg_replace('#[^0-9]#', '', $_POST['statusid']); // check to see which page the user is on, then give different variables that contain different DB tables // check to see whether or not the user replied to a status from user.php or watch.php if($_POST['document'] == "comments") // this means the user replied within watch.php { $DB_table = "comments"; } else if($_POST['document'] == "status") // this mean that the user replied within user.php { $DB_table = "status"; }else{ echo 'Error: this is an unexpected situation. What is happening? ' . $_POST['document']; } // Check to make sure the person deleting this reply is either the account owner or the person who wrote it if($DB_table == null){ echo 'Can\'t look up nuthin'; }else{ // Check to make sure the person deleting this reply is either the //account owner or the person who wrote it $sql = "SELECT account_name, author FROM $DB_table WHERE id='$statusid' LIMIT 1"; $query = mysqli_query($con, $sql); while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { $account_name = $row["account_name"]; $author = $row["author"]; } } // delete the thread and it replies with the same osid if ($author == $log_username || $account_name == $log_username) { $sql = "DELETE FROM $DB_table WHERE osid='$statusid'"; mysqli_query($con, $sql); echo "delete_ok"; exit(); } } ?>
  11. Hello Guys... I have one problem in javascript guys help me i'am begginer in javascript and jquery if user has enter value in textbox then he can't move on another screen before save the value of textbox if user click on Add or Edit Button the alert box print message 'Save the Value' it's ok . but when i click on Save button, i don't want alert box to save the textbox value <script type="text/javascript"> $(document.body).click(function(){ return check(); }); </script> <script type="text/javascript"> function check() { var txt = document.getElementById('txtbox').value; if(txt !== '') { alert('Save the Value'); } } </script> <input type="text" name="txtbox" id="txtbox"><br/> <input type="submit" name="btn1" id="btn1" value="Save"><br/> <input type="submit" name="btn2" id="btn2" value="Add"><br/> <input type="submit" name="btn3" id="btn3" value="Edit"><br/>
  12. Hello, I have written a code to use google map drawing tools to draw polygon, circle and point on the googlemap, i need to capture and store these drawing in my postgresql database and also be able to display the store data back on the map when queried. I need someone to look at my code and tell me how I can achieve this. The google map and the drawings functions well, i know i need to create a table in the database to capture the geometric information of the drawings which i have also done. but the table doesnt seem to be populating. i believe something is wrong with my code and i need help from anyone who has successfully done this in the past Thanks <?php $host = "host=localhost"; $port = "port=5432"; $dbname = "dbname=LS"; $credentials = "user=postgres password=carol74"; $db = pg_connect( "$host $port $dbname $credentials" ); if(!$db){ echo "Error : Unable to open database\n"; } else { echo "Opened database successfully\n"; } ?> <!DOCTYPE html> <head> <title>LSInfo Recording tool</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <style> html, body, #map { height: 90%; margin: 10px; padding: 0px } </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&libraries=drawing,geometry"></script> <script> var coordinates = []; var all_shapes = []; var selectedShape; function draw_shape() { for(var i = 0; i < all_shapes.length; i++) { all_shapes[i].setMap(null); } for(var i = 0; i < all_shapes.length; i++) { all_shapes[i].setMap(map); } } function clearSelection() { if(selectedShape) { selectedShape.setEditable(false); selectedShape = null; } } function setSelection(shape) { clearSelection(); selectedShape = shape; shape.setEditable(true); } function deleteSelectedShape() { if (selectedShape) { selectedShape.setMap(null); } } function save_coordinates_to_array(newShapeArg) { if(newShapeArg.type == google.maps.drawing.OverlayType.POLYGON) { var polygonBounds = newShapeArg.getPath(); for(var i = 0 ; i < polygonBounds.length ; i++) { coordinates.push(polygonBounds.getAt(i).lat(), polygonBounds.getAt(i).lng()); } } else { //alert("Not polygon");///////////// } } var map; function initialize() { map = new google.maps.Map(document.getElementById('map'), {zoom: 12, center: new google.maps.LatLng(7.07859, 5.64392)}); var drawingManager = new google.maps.drawing.DrawingManager(); drawingManager.setMap(map); google.maps.event.addListener(drawingManager, 'overlaycomplete', function(e) { var newShape = e.overlay; newShape.type = e.type; all_shapes.push(newShape); setSelection(newShape); save_coordinates_to_array(newShape); google.maps.event.addListener(newShape, 'click', function() {setSelection(newShape)}); }); google.maps.event.addListener(map, 'click', function(e) {clearSelection();}); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <h1>Property identifcation program</h1> <h2> Please Use the Tools shown on the map to markout your parcel location</h2> <div class="map" id="map-canvas"></div> <form method="post" action="" name="informarionForm" id="informarionForm" ><!--onsubmit="save_details(); return false;"--> <p><b></b> <table width="1100" cellpadding="10" cellspacing="0" border="1" align="center"> <tr align="center" valign="top"> <td align="center" colspan="1" rowspan="1" bgcolor="#FF8000"> <table style="width:80%" > <h3>sketch your property location on the Map!!</h3> <tr> Title_holder: <?php $sql =<<<EOF SELECT * from tblperson; EOF; $ret = pg_query($db, $sql); echo'<select name="Title_holder">'; while($row = pg_fetch_assoc($ret)){ echo "<option value=".$row["person_id"].">".$row["first_name"]."</option>"; //print_r($row); } echo '</select>'; ?> </tr> Title_Type: <?php $sql =<<<EOF SELECT * from ownership_type; EOF; $ret = pg_query($db, $sql); echo'<select name="Ownership" id="Ownership">'; while($row = pg_fetch_array($ret)){ $id = $row["type_id"]; if($id == $row["type_id"]){ echo 'selected'; } echo "<option value=".$row["type_id"].">".$row["type_description"]."</option>"; //print_r($row); } echo '</select>'; ?> </tr> <tr> Select boundary identifier: <?php $sql =<<<EOF SELECT * from boundaryidentificationtable; EOF; $ret = pg_query($db, $sql); echo'<select name="boundary_identifier">'; while($row = pg_fetch_array($ret)){ echo "<option value=".$row["boundary_id"].">".$row["boundary_type"]."</option>"; } echo '</select>'; ?> </tr> <tr> Media_Type: <?php $sql =<<<EOF SELECT * from lutmediatypes; EOF; $ret = pg_query($db, $sql); echo'<select name="lutmediatypes">'; while($row = pg_fetch_array($ret)){ echo "<option value=".$row["media_type_id"].">".$row["media_type"]."</option>"; } echo '</select>'; ?> </tr> <p></p> <tr> Select_Media: <?php $sql =<<<EOF SELECT * from tblmedia; EOF; $ret = pg_query($db, $sql); echo'<select name="tblmedia">'; while($row = pg_fetch_array($ret)){ echo "<option value=".$row["media_id"].">".$row["file_name"]."</option>"; } echo '</select>'; ?> <td>Capture boundaryline geometry from Map </td> <td><input name="the_geom2" type="text" id="the_geom2" ></td></td> </tr> <tr> <td>Capture Parcel Geometry from Map </td> <td><input name="the_geom" type="text" id="polygeom" ></td></td> </tr> <tr> <td>Add your description for this parcel:</td> <td><textarea cols="20" name="comments" rows="3" ></textarea></td> </tr> <td> </td> <td> <input name="Submit1" type="button" onclick="save_details();" value="Submit Information." ></td> </tr> </table> <p></p> <table width="700" cellpadding="10" cellspacing="0" border="1"> <tr align="center" valign="top"> <td align="center" colspan="1" rowspan="1" bgcolor="#CCCCCC"> <table style="width: 100%"> <h3>Identify other Useful Land resources and economic trees on your parcel</h3> <tr> Landuse:<?php $sql =<<<EOF SELECT * from landusetable; EOF; $ret = pg_query($db, $sql); echo'<select name="Landuse">'; while($row = pg_fetch_array($ret)){ echo "<option value=".$row["landuse_id"].">".$row["landuse_type"]."</option>"; } echo '</select>'; ?> </tr> <p></p> <tr> <td>Input Resource Name (tree; pond_water):</td> <td><textarea cols="20" name="comments" rows="3" ></textarea></td> </tr> <tr> Select media to upload(video, audio, picture or text): <?php $sql =<<<EOF SELECT * from tblmedia; EOF; $ret = pg_query($db, $sql); echo'<select name="tblmedia">'; while($row = pg_fetch_array($ret)){ echo "<option value=".$row["media_id"].">".$row["file_name"]."</option>"; } echo '</select>'; ?> <tr> <td>Preview Media(video, audio, picture or text)</td> <td><input name="previewVideo" type="text"></td> </tr> <tr> <td> </td> <td> <input name="Submit1" type="button" onclick="save_details();" value="Submit Information." ></td> </tr> </table> </form> </body> </html>
  13. What's wrong with this simple script to call 2 functions: if (up < max){ lower.onclick=min_function; } else if (up > min) { lower.onclick=max_function; }
  14. Hi, i've recently been learning javascript, and i've found that sometimes code works when it shouldn't, even though it throws an error. The Problem First, i need to explain that i am using two separate onclick events here. The first acts on the class of the toggle button, hiding the other toggleable divs then loading the unique one by id. the second onclick event fires specifically on the id to load the twitter feed. the problem is that the twitter feed finishes loading before the show() animation completes on the div, making the feed render at about half the size of the div, when its suppose to be 100% minus padding. We all know that loading a twitter feed can add unnecessary lag to a page, so i created a way to load it dynamically when the feed is slidetoggled onto the screen, like so: The Solution: function getTweets() { !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https'; if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); } The side effect Now that i've loaded the twitter feed in this method, due to animations(a timer set on the show() method that makes the box appear to "grow", the twitter feed renders at half the size of the div, because the code is called for the twitter feed before the animation has completed. The Nitty Gritty Hack to make it work At first i thought i had solved the problem with this, but really i'm just preloading the twitter box, which means all of my work was for naught: getTweets().finish( function() { resizeTweetbox();//this throws an error but still works }); here's the resizeTweetbox() function for reference: function resizeTweetBox() { $("#twitter-widget-0").css("width","100%"); } I'm wondering if there is a better way i can do this. its one of those weird situations where i can't just add the function to the onclick function of the class, because its unique to the twitter feed's div. if you need to take a look my site is located at https://openex.info Thanks for your time. Garrett
  15. Hi, I'm trying to let JavaScript check if a givin user exist in the database. It seems that the _check-user.php always returns 0, but if I fill in a name that doesn't exist, and echo out the result variable in JS, the echo will return 1. Is there someone who could help me? JavaScript part: function checkUser() { $.post("_check_user.php", { 'username': document.getElementById("username").value }, function(result) { if (result == 1) { document.getElementById("checkUser").className = "succes"; document.getElementById("checkUser").innerHTML = "Name is available"; }else{ document.getElementById("checkUser").className = "errormsg"; document.getElementById("checkUser").innerHTML = "Name is not available!"; } }); } _check-user.php: <?php include("config.php"); $result = mysql_query("SELECT login FROM users WHERE login='".clean_string($_POST["username"])."'"); if(mysql_num_rows($result)>0){ echo 0; }else{ echo 1; } ?>
  16. I am looking for a script to make a photo gallery exactly like the one iTunes uses. This is what it looks like: I want all of the same functionalities as this one has and I need to be able to put it inside of a web page easily and sized the way I will need it. The images displayed in this gallery must auto-resize and open in a new tab as the original file when clicked on. I need the iPhone and iPad screen view options to both be there and if there aren't any images for one or the other, the button to switch isn't displayed or is inactive. If you could write this script or give me source code, that'd be great as I really need it for my new site I am developing. Please make it look exactly the same
  17. <style> .msgBox{ position:absolute; z-index:10; border-radius:5px; border:1px solid #F5F5F5; background-color:#DDD; box-shadow:1px 1px 5px #999; overflow:hidden; display:none} .msgBox ul, .msgBox li{ list-style:none; padding:0; margin:0; border:0} .msgBox .title{ border-bottom:#AAA solid 1px; padding:5px; background-color:#CCC; font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight:bold; text-shadow:1px 1px #DDD; font-size:12px} .msgBox .msgContent{ border-top:#F5F5F5 solid 1px; padding:5px; text-shadow:1px 1px #F1F1F1; font-family:Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif; font-size:12px} .msgBox .ok{ text-shadow:1px 1px #F1F1F1; font-family:Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif; font-size:12px; margin:0 auto 5px auto; width:20px; padding:4px 5px 4px 5px; background-color:#CCC; text-align:center; cursor:pointer; transition:all 300ms linear; border:#DDD solid 1px; box-shadow:0 0 1px #AAA; border-radius:4px} .msgBox .ok:hover{ background-color:#EEE} </style> <div class="msgBox"> <ul class="title">Alert</ul> <ul class="msgContent">No messege</ul> <ul> <li class="ok">Ok</li> </ul> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script language="javascript"> // Upgraded confirm function var msgBox = function(msg){ var w =$(document).width(), h = $(document).height(); var msgW = $('.msgBox').width(), msgH = $('.msgBox').height(); $('.msgBox').css({left:(w-msgW)/2, top:(h-msgH)/2}); $('.msgBox') .show() .find('.msgContent').text(msg); $('.msgBox').find('.ok').click(function(){ $('.msgBox').hide(); }); $(document).keyup(function(event){ if(event.which==13){ $('.msgBox').hide(); } }); } msgBox('Enter your message!'); </script> Demo: http://www.yepi3games.org/alert.htm
  18. Hello all, I am quite stuck with the validation part with different requirement in validation. Below is the list which i am working for my application module: a. Form will consist of two input fields (name and email) and a submit button. b. On submit, the validation should check if the fields are empty. c. If any field is empty, the text colour as well as border of the field should turn red. (No need to show an error message) d. When I start typing in the field, The text and border colour should return to default colour. Below is the code which i had tried: <center> <table border="1" > <tr> <td> <form name = "registerationform" method="POST" action="welcome.html" onsubmit="return(regvalidate())"> <table> <tr> <td>First Name: </td> <td><input type = "text" name="fnametxt" /><br/> </td> </tr> <tr> <td>Second Name: </td> <td> <input type = "text" name="snametxt" /><br/></td> </tr> <tr> <td> User Name:</td> <td><input type = "text" name="unametxt" /><br/> </td> </tr> <tr> <td>Email Address: </td> <td> <input type = "text" name="emailtxt" /><br/></td> </tr> </tr> <tr> <td> Password : </td> <td> <input type = "password" name="pwdtxt" /> <br/> </td> </tr> </tr> <tr> <td> Confirm : </td> <td> <input type = "password" name="cpwdtxt" /> <br/> </td> </tr> </table> <font color='red'> <DIV id="une"> </DIV> </font> <input type = "submit" value="Register Now" /> </form> </td> </th> </tr> </table> </tr> </table> </tr> <SCRIPT type="Text/JavaScript"> function regvalidate() { if((document.registerationform.fnametxt.value=="")&&(document.registerationform.snametxt.value=="")) { document.getElementById('une').innerHTML = "First name or Second name should not be empty"; registerationform.fnametxt.focus(); return(false); } if(document.registerationform.unametxt.value=="") { document.getElementById('une').innerHTML = "User name field should not be empty"; registerationform.unametxt.focus(); return(false); } if(document.registerationform.emailtxt.value=="") { document.getElementById('une').innerHTML = "Email id requered"; registerationform.emailtxt.focus(); return(false); } if(document.registerationform.pwdtxt.value=="") { document.getElementById('une').innerHTML = "Please type a password"; registerationform.pwdtxt.focus(); return(false); } if((document.registerationform.pwdtxt.value) != (document.registerationform.cpwdtxt.value)) { document.getElementById('une').innerHTML = "Password Must be equal"; registerationform.pwdtxt.value = ""; registerationform.cpwdtxt.value = ""; registerationform.pwdtxt.focus(); return(false); } else { return(true); } } </SCRIPT> </td> </tr> </table> </center> The above form works for all the fields but i need only two as specified above as well as the textbox border coloring for errors. Really need help. If someone could plese help me out
  19. I'm looking for something like iPython is for Python, but a shell for JavaScript. If you don't know iPython, what I'm looking for is a terminal that interpret JavaScript codes in real time, so I can type some commands and see their output. I always find this kind of interpreter very useful when I'm learning a new language. Thanks!
  20. Hi! I've been fighting with this for a few days now and I'm really getting tired of it. If I copy and paste everything within the body tag, as well as everything in the contact.js file into JSFiddle, everything works great. When I click on "Consumer" an additional DIV of questions appears. Fantastic! However, when I take everything that's in the functioning (on JSFiddle) body tag and put it with the rest of the file, it doesn't work. I thought it wasn't connecting to the JQuery library, but when I remove that line of code, the validation (that worked before) stops working, so I don't think that's it. I'm sure it's something stupidly simple, but I'm out of ideas. Any help would be AWESOME! The contents of the contact.js file (the radio button part is at the bottom) can be seen on the JSFiddle. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Have Questions?</title> <link rel="shortcut icon" href="/template_imgs/favicon.ico" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../css/coastal-styles.css" rel="stylesheet" type="text/css" media="all" /> <link href="../css/contact.css" rel="stylesheet" type="text/css" media="all" /> <script src="../includes/jquery-1.6.4.min.js" type="text/javascript" charset="utf-8"></script> <script src="../includes/jquery.validate.js" type="text/javascript" charset="utf-8"></script> <script src="../includes/jquery.form.js" type="text/javascript" charset="utf-8"></script> <script src="../includes/jquery.metadata.js" type="text/javascript" charset="utf-8"></script> <script src="../includes/contact.js" type="text/javascript" charset="utf-8"></script> <html> <body> <div id="container"> <?php include($_SERVER[ 'DOCUMENT_ROOT']. '/includes/header.php'); ?> <div class="page-heading clear" style="background-image: none; height: 20px;"> <div class="breadcrumbs"><a href="../index.php">Home</a> > <a href="index.php">Contact Us</a> </div> </div> <div class="content"> <h1>Contact Us</h1> <p>Have questions? For your convenience our Customer Service Representives are available from 8:30 AM - 5:00 PM (Eastern Standard Time) Monday through Friday.</p> <p>All fields marked with <span class="required">*</span> are required.</p> <br /> <div id="contact-form" class="floatLeft rounded-corners"> <form method="post" action="contact_form_process.php" id="cform" onsubmit="return validateForm()"> <p> <label for="cname" class="main-label"><span class="required"> * </span>Your Name</label> <input id="cname" name="name" class="required" /> </p> <p> <label for="ccompany" class="main-label">Company</label> <input id="ccompany" name="company" /> </p> <p> <label for="caddress" class="main-label"><span class="required"> * </span>Address</label> <input id="caddress" name="address" class="required" /> </p> <p> <label for="ccity" class="main-label"><span class="required"> * </span>City</label> <input id="ccity" name="city" class="required" /> </p> <p> <label for="cstate" class="main-label"><span class="required"> * </span>State</label> <input id="cstate" name="state" class="required" /> </p> <p> <label for="czipcode" class="main-label"><span class="required"> * </span>Zip</label> <input id="czipcode" name="zipcode" class="required" /> </p> <p> <label for="ccountry" class="main-label"><span class="required"> * </span>Country</label> <input id="ccountry" name="country" class="required" /> </p> <p> <label for="cphone" class="main-label"><span class="required"> * </span>Phone</label> <input id="cphone" name="phone" class="required" /> </p> <p> <label for="cfax" class="main-label">Fax</label> <input id="cfax" name="fax" /> </p> <p> <label for="cwebsite" class="main-label">Website</label> <input id="cwebsite" name="website" /> </p> <p> <label for="ccontact"><span class="required"> * </span>E-Mail</label> <input id="ccontact" name="contact" class="required email" /> </p> <p> <label for="ccomments" id="ccomments-label" class="main-label"><span class="required"> * </span>Comments</label> <textarea id="ccomments" name="comments" class="required" rows="6" cols="6"></textarea> </p> <p>If you are contacting us about a product, please include as much information as possible (e.g. date of purchase, description of the item and nature of problem).</p> <p class="radio-questions"> <b>How did you hear about our website?</b> <br /> <span class="radio-wrapper"> <label class="referred-label" for="cReferred-Search"> <input type="radio" id="cReferred-Search" name="referred" value="Search_Engine" /> Search engine </label> <label class="referred-label" for="cReferred-Friend"> <input type="radio" id="cReferred-Friend" name="referred" value="Friend" /> Friend </label> <label class="referred-label" for="cReferred-Ad"> <input type="radio" id="cReferred-Ad" name="referred" value="Magazine_Ad" /> Magazine Ad </label> <label class="referred-label" for="cReferred-Packaging"> <input type="radio" id="cReferred-Packaging" name="referred" value="Product_Packaging" /> Product Packaging </label> <label class="referred-label" for="cReferred-Other"> <input type="radio" id="cReferred-Other" name="referred" value="Other" /> Other </label> </span> </p> <p> <label class="radioerror error" for="referred">This field is required.</label> </p> <div class="clear"></div> <div class="CustType" <p class="radio-questions"> <b>Check appropriate box.</b> <br /> <span class="radio-wrapper"> <label class="CustomerType-label" for="cCustomerType-Consumer"> <input type="radio" id="cCustomerType-Consumer" name="CustomerType" value="Consumer" /> Consumer </label> <label class="CustomerType-label" for="cCustomerType-Wholesale"> <input type="radio" id="cCustomerType-Wholesale" name="CustomerType" value="Wholesale" /> Wholesale Distributor </label> <label class="CustomerType-label" for="cCustomerType-Retail_Store"> <input type="radio" id="cCustomerType-Retail_Store" name="CustomerType" value="Retail_Store" /> Retail Store </label> <label class="CustomerType-label" for="cCustomerType-Mailorder"> <input type="radio" id="cCustomerType-Mailorder" name="CustomerType" value="Mailorder" /> Mail Order Catalog </label> <label class="CustomerType-label" for="cCustomerType-Other"> <input type="radio" id="cCustomerType-Other" name="CustomerType" value="Other" /> Other </label> </span> </p> </div> <p> <label class="radioerror error" for="CustomerType">This field is required.</label> </p> <div class="ConsQ"> <p class="radio-questions"> <b>What can we help you with?</b> <br /> <span class="radio-wrapper"> <label class="ConsumerHelp-label" for="cConsumerHelp-Use"> <input type="radio" id="cConsumerHelp-Use" name="ConsumerHelp" value="Use" /> Proper Use of a Product </label> <label class="ConsumerHelp-label" for="cConsumerHelp-Sizing"> <input type="radio" id="cConsumerHelp-Sizing" name="ConsumerHelp" value="Sizing" /> Sizing Information </label> <label class="ConsumerHelp-label" for="cConsumerHelp-Performance"> <input type="radio" id="cConsumerHelp-Performance" name="ConsumerHelp" value="Performance" /> Product Didn't Perform as Expected </label> <label class="ConsumerHelp-label" for="cConsumerHelp-Locate"> <input type="radio" id="cConsumerHelp-Locate" name="ConsumerHelp" value="Locate" /> Finding Product at a Retail Location </label> <label class="ConsumerHelp-label" for="cConsumerHelp-Other"> <input type="radio" id="cConsumerHelp-Other" name="ConsumerHelp" value="Other" /> Other </label> </span> </p> <p> <label for="cUPC" class="main-label">Please provide the UPC or Item # of the product you are referencing.</label> <input id="cUPC" name="UPC" /> </p> </br> </br> <p> <label for="cDescribe" id="cDescribe-label" class="main-label"><span class="required"> * </span>Please describe what you are looking for.</label> <textarea id="cDescribe" name="Describe" class="required" rows="6" cols="6"></textarea> </p> </div> <br clear="all"></br> <p>Please help us fight spam.</p> <p> <label for="cbot" class="main-label"><span class="required"> * </span>Please enter a number lower than 5.</label> <input id="txt_qty" name="qty" class="required" /> </p> <div class="special"> <input id="realemail" name="email" type="text" /> </div> <p class="formbuttons"> <input name="submit" type="submit" value="Submit" /> </p> </form> </div> </div> </body> <?php include( '../includes/footer.php'); ?> </html>
  21. hi all! first let me be clear - the ajax skeletal of the script is not the issue here. I have been working through night to ensure those portions are all functioning properly. i successfully load an xml document with the value of selected for each service, eiter displayed as selected or a blank string. however - when i attempt to select the selected service (in memory) in the dropdown after refreshing the xml, it selects nothing... could an bright sparks perhaps assist me in locating and resolving the issue? below is the relevant javascript portions: // parse services xml (this works perfectly so please do not think it is at fault if "unable to see the forest for the lemons") var services = xmldoc.getElementsByTagName("service"); var arr10 = new Array(); servicearr = new Array(); for (var x = 0; x < services.length; x++) { if (services[x].attributes.getNamedItem("sid") && services[x].attributes.getNamedItem("desc") && services[x].attributes.getNamedItem("selected") && indexOf.call(servicearr,services[x].attributes.getNamedItem("sid").nodeValue)==-1) { var arr = new Array(); var aa = 0; var arr1 = new Array(); arr[0] = services[x].attributes.getNamedItem("sid").nodeValue; arr[1] = services[x].attributes.getNamedItem("desc").nodeValue; arr[2] = services[x].attributes.getNamedItem("selected").nodeValue; var i = 1; for (var c = 0; c < services[x].childNodes.length; c++) { if (services[x].childNodes[c].nodeName == "attribute" && services[x].childNodes[c].attributes.getNamedItem("id").nodeValue != undefined) { var arr2 = new Array(); arr2[0] = services[x].childNodes[c].attributes.getNamedItem("id").nodeValue; arr2[1] = services[x].childNodes[c].attributes.getNamedItem("desc").nodeValue; arr2[2] = services[x].childNodes[c].attributes.getNamedItem("val").nodeValue; arr2[3] = services[x].childNodes[c].attributes.getNamedItem("ord").nodeValue; arr2[4] = (services[x].childNodes[c].attributes.getNamedItem("ptr").nodeValue!="")?services[x].childNodes[c].attributes.getNamedItem("ptr").nodeValue:""; arr1[aa] = arr2.join(";;;"); aa++; } } arr[3] = arr1.join(";.;"); // service attributes //salert(arr); if (arr.length) { addrecord("menu_services", arr); servicearr.push(arr[0]); svc = true; } } } // single addrecord function function addrecord(id, arr) { salert(id); salert(arr[0]); salert(arr[1]); salert(arr[2]); var opt0 = document.createElement("option"); //salert(arr[i]); opt0.text = arr[1]; // value 1 text service name opt0.value = arr[0] + "|;|" + // value 0 service id arr[2] + "|;|" + // save selection flag ("selected" or "") arr[3]; // save the value 3 attribute keys/values/order array string opt0.selected = (arr[2]=="selected")?true:false; var sel = document.getElementById(id); try { sel.add(opt0, null); // standards compliant; doesn't work in IE } catch(ex) { sel.add(opt0); // IE only } if (arr[2] == "selected") { sid = arr[0]; // save sid if selected! //sel.selectedIndex = sel.options.length-1; } } to prove that the xml loads correctly - here is an excerpt with the Bakky Canopy service... <root> <service sid="10" desc="Accounting Bookkeeping" selected="">...</service> <service sid="1" desc="Bakkie Canopy" selected="selected">...</service> <service sid="3" desc="Bakkie Canopy Accessories" selected=""></service> <service sid="2" desc="Bakkie Linings & Rubberizing" selected=""></service> <service sid="15" desc="Broadband Internet" selected="">...</service> <service sid="5" desc="Business Phone Systems" selected="">...</service> <service sid="9" desc="Company Registrations" selected="">...</service> <service sid="11" desc="Conference Venues" selected="">...</service> <service sid="8" desc="Debt Collection Agencies" selected="">...</service> <service sid="17" desc="Office Coffee" selected="">...</service> <service sid="7" desc="Office Colour Printers" selected="">...</service> <service sid="12" desc="Office Furniture" selected="">...</service> <service sid="13" desc="Office Movers" selected="">...</service> <service sid="14" desc="Office Network Cabling" selected="">...</service> <service sid="6" desc="Office Printers & Copiers" selected="">...</service> <service sid="16" desc="Office Water" selected="">...</service> <service sid="4" desc="Placeholder" selected=""></service> <sql/> </root> as can be seen in the xml and javascript - the service id 1 should load as default selected service id... i am hereby requesting javascripters with great insightto see what i do not - the services all load, but none are selected in the html web form. many thanks in advance to the one (or more) whom with crystal clarity, can resolve this. sincerely - Pierre "Greywacke" du Toit
  22. Hi, I am currently building a site which works perfectly as it is. However, I am now trying to add mobile responsiveness and having trouble with what I think is the order in which the JavaScript files are loading. Essentially, I have a slideshow on the main page but I don't want this to load on mobile devices so am using Enquire.js to set some parameters. However, even though it looks like it's working in the code there are some problems. First off, in my script, I load the JavaScript files: <script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script> <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js" type="text/javascript" charset="utf-8"></script> Then I load the loadJS function and initialise the jQuery tool: <script type="text/javascript"> function loadJS(url) { var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = url; head.appendChild(script); }; (function($) { jQuery('#slides').slides({ preload: true, generateNextPrev: true }); }); </script> This all works fine. My problem is that I want jQuery Tools to only open if the computer is not a mobile. So, instead of loading the script in the header I have this script later on in the file: enquire.register("screen and (min-width: 900px)", { match : function() { loadJS('http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js'); console.log('desktop loaded'); } }); However, even though that script loads the JavaScript in the header the jQuery Tools are not initialising properly and the slideshow is not working. Why is this happening? Any help even with how I can debug this would be really appreciated. Thanks, Russ
  23. <input onkeyup="s?e=Date.now():s=Date.now()"onblur="c=this.value.length;this.value+=c/(e-s)"><script>s=0</script> <script>s=0</script> Once this executes - it's completely needless. But without s=0 there are no s, e variables. With = OK. How is it logically possible to reduce keeping it short?
  24. The idea is simple. A key you press (a letter) appears in updated page: keyj.php: <input id='k'></input> <script type="text/javascript"> document.getElementById('k').onkeypress=function() { <?php $db=new PDO('mysql:host=localhost;dbname=test;charset=utf8','$us','$ps'); $db->exec("UPDATE TXT SET texts=k.value"); $rl=$db->query("SELECT texts FROM TXT"); print_r($rl->fetchColumn()); ?> } </script> The intention is to have text on the screen via print_r. I successfully used it in another php to exchange information with MySQL and users screen (worked). Here - the more you type and the more k.value is the more text will be on screen (just from server). Unfortunately something went wrong.
  25. All I want to do is simply delete a record/row using ajax. For the life of me, I can't get it to work. I have tried many different methods and played around with them. Here is a basic example. Please do tell me what's wrong with it and how I can fix it. index.php <html> <head> <title>Home page</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> $(document).ready(function() { $(function() { $(".del-action").click(function() { var commentContainer = $(this).parent(); var id = $(this).attr("id"); var string = 'id='+ id ; $.ajax({ type: "GET", url: "delete.php", data: string, cache: false, }); }); </script> </head> <body> <?php $get = DB::getInstance()->query("SELECT * FROM records WHERE record_id = 28 "); if(!$get->count()) { echo 'no record found!'; } else { foreach($get->results() as $row) { $record_id = $row->record_id; ?> <div class="record"> <a href="#" class="del-action" id="<?php echo $record_id; ?>" >Delete</a> </div> <?php } } ?> </body> </html> delete.php $record_id = intval($_GET['id']); $delete = DB::getInstance()->delete('records', array('record_id', '=', $record_id)); ps. it deletes the records fine without ajax/js. I just need help with the js code so that I can delete the record without redirecting or refreshing the page.
×
×
  • 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.