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. 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
  2. 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/
  3. 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>
  4. 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?
  5. 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.
  6. 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();
  7. 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(); } } ?>
  8. 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/>
  9. 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>
  10. 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; }
  11. 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
  12. 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; } ?>
  13. 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
  14. <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
  15. 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
  16. 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!
  17. 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>
  18. 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
  19. 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
  20. <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?
  21. 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.
  22. 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.
  23. I am trying to have a js alert box to confirm before deleting a record. Here is the js code. <script> function confirmation() { var answer = confirm("Are you sure?") if (answer){ alert("This record been deleted!") } else{ alert("Not deleted!") } } </script> php code. <a href="delete.php" onclick="confirmation()">Delete record</a> The problem is, even if i click no in the js alert box and the message shows("Not deleted!"), it still deletes the record. Why is it doing that? My second question is, is it possible to css the js alert box? I need to customize it to my own look.
  24. This is a script that validates a user's email and password. Everything is super clear but I can't figure out the purpose of document.getElementById('theForm').submit(); As far as I know, it's a method that submits the form to the script referenced inside the forms html action tag eg. <form action="login.php"> (just in case ajax fails for whatever reason). But I can't find any information to validate this. function validateForm() { 'use strict'; // Get references to the form elements: var email = document.getElementById('email'); var password = document.getElementById('password'); // Validate! if ( (email.value.length > 0) && (password.value.length > 0) ) { // Perform an Ajax request: var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange = function() { if (ajax.readyState == 4) { // Check the status code: if ( (ajax.status >= 200 && ajax.status < 300) || (ajax.status == 304) ) { if (ajax.responseText == 'VALID') { alert('You are now logged in!'); } else { alert('The submitted values do not match those on file!'); } } else { document.getElementById('theForm').submit(); } } }; ajax.open('POST', 'resources/login.php', true); ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); var data = 'email=' + encodeURIComponent(email.value) + '&password=' + encodeURIComponent(password.value); ajax.send(data); return false; } else { alert('Please complete the form!'); return false; } } // End of validateForm() function. // Function called when the window has been loaded. // Function needs to add an event listener to the form. function init() { 'use strict'; // Confirm that document.getElementById() can be used: if (document && document.getElementById) { var loginForm = document.getElementById('loginForm'); loginForm.onsubmit = validateForm; } } // End of init() function. // Assign an event listener to the window's load event: window.onload = init;
  25. I'm having a bit of trouble with a PHP contact form. There are issues with the error messages not showing on the form, the form not resetting, and the "name" input appearing as "X-AuthUser: XXX123 (which happens to be my FTP user name which I'm keeping private) when the email is sent to my gmail account. This is how the theme should look: http://pluto.html.themewoodmen.com/07-pluto-contact.html And this is what I have: http://divagraphics.us/test/contact.html The HTML <div class="contactForm"> <div class="successMessage alert alert-success alert-dismissable" style="display: none"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> Thank You! E-mail was sent. </div> <div class="errorMessage alert alert-danger alert-dismissable" style="display: none"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> Ups! An error occured. Please try again later. </div> <form class="liveForm" role="form" action="form/send.php" method="post" data-email-subject="Contact Form" data-show-errors="true" data-hide-form="false"> <fieldset> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label class="control-label">Name <span>(Required)</span></label> <input type="text" required name="name" class="form-control" id="name"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="control-label">Email <span>(Required)</span></label> <input type="email" required name="email" class="form-control" id="email"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Subject</label> <input type="text" name="subject" class="form-control" id="subject"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Message <span>(Required)</span></label> <textarea name="message" required class="form-control" rows="5" id="message"></textarea> </div> </div> </div> <input type="submit" class="btn btn-primary" value="Send Message"> </fieldset> </form> </div> The JS /** * Contact Form */ jQuery(document).ready(function ($) { "use strict"; $ = jQuery.noConflict(); var debug = false; //show system errors $('.liveForm').submit(function () { var $f = $(this); var showErrors = $f.attr('data-show-errors') == 'true'; var hideForm = $f.attr('data-hide-form') == 'true'; var emailSubject = $f.attr('data-email-subject'); var $submit = $f.find('[type="submit"]'); //prevent double click if ($submit.hasClass('disabled')) { return false; } $('[name="field[]"]', $f).each(function (key, e) { var $e = $(e); var p = $e.parent().find("label").text(); if (p) { var t = $e.attr('required') ? '[required]' : '[optional]'; var type = $e.attr('type') ? $e.attr('type') : 'unknown'; t = t + '[' + type + ']'; var n = $e.attr('name').replace('[]', '[' + p + ']'); n = n + t; $e.attr('data-previous-name', $e.attr('name')); $e.attr('name', n); } }); $submit.addClass('disabled'); $f.append('<input class="temp" type="hidden" name="email_subject" value="' + emailSubject + '">'); $.ajax({ url: $f.attr('action'), method: 'post', data: $f.serialize(), dataType: 'json', success: function (data) { $('span.error', $f).remove(); $('.error', $f).removeClass('error'); $('.form-group', $f).removeClass('has-error'); if (data.errors) { $.each(data.errors, function (i, k) { var input = $('[name^="' + i + '"]', $f).addClass('error'); if (showErrors) { input.after('<span class="error help-block">' + k + '</span>'); } if (input.parent('.form-group')) { input.parent('.form-group').addClass('has-error'); } }); } else { var item = data.success ? '.successMessage' : '.errorMessage'; if (hideForm) { $f.fadeOut(function () { $f.parent().find(item).show(); }); } else { $f.parent().find(item).fadeIn(); $f[0].reset(); } } $submit.removeClass('disabled'); cleanupForm($f); }, error: function (data) { if (debug) { alert(data.responseText); } $submit.removeClass('disabled'); cleanupForm($f); } }); return false; }); function cleanupForm($f) { $f.find('.temp').remove(); $f.find('[data-previous-name]').each(function () { var $e = jQuery(this); $e.attr('name', $e.attr('data-previous-name')); $e.removeAttr('data-previous-name'); }); } }); The PHP <?php // Contact subject $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $to = "divagraphicsinc@gmail.com"; $from = $_POST['email']; $headers = "From: $from"; mail($to,$subject,$message,$headers) ?>
×
×
  • 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.