Search the Community
Showing results for tags 'javascript'.
-
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(); } } ?>
-
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/>
- 1 reply
-
- jquery
- javascript
-
(and 1 more)
Tagged with:
-
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>
-
- php
- postgresql
-
(and 3 more)
Tagged with:
-
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; }
- 3 replies
-
- flipper
- javascript
-
(and 2 more)
Tagged with:
-
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
-
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; } ?>
- 1 reply
-
- javascript
- check
-
(and 3 more)
Tagged with:
-
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
-
<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
-
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
-
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!
- 2 replies
-
- javascript
- shell
-
(and 1 more)
Tagged with:
-
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>
- 3 replies
-
- javascript
- form
-
(and 1 more)
Tagged with:
-
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
-
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
-
<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?
- 1 reply
-
- script
- javascript
-
(and 1 more)
Tagged with:
-
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.
- 2 replies
-
- javascript
- php
-
(and 3 more)
Tagged with:
-
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.
- 2 replies
-
- javascript
- ajax
-
(and 3 more)
Tagged with:
-
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.
- 2 replies
-
- php
- javascript
-
(and 3 more)
Tagged with:
-
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;
-
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) ?>
- 2 replies
-
- php
- contact form
-
(and 3 more)
Tagged with:
-
function updateTimers() { //Get the current timestamp now = new Date(); //Iterate through each of the timers for(i=0; i<timers.length; i++) { //Convert end time to timestamp & calc difference endTime = new Date(timers[i].split(' ').join('T')); millisecondsDiff = endTime - now; //Format the diff and display timeDisplay = formatTimeDiff(millisecondsDiff); document.getElementById('timer['+i+']').innerHTML = timeDisplay; } } I'm using the above function to set timers for a page on my website. It should be showing 23 minutes but is showing 83 minutes. This has only come about since the clocks in the UK went forward. Ant help?
-
Here is a script i wrote so i could refresh a div with content every 5 seconds but for some reason it doesnt work ... i wanted it to load it with the page then start the refresh i didnt want it to have to wait for the refresh to show up. <script type="text/javascript"> function page_load(){ $('#contentforads').load('<?php print $actual_link ?>/ads.php').fadeIn("slow"); } function refresh(){ page_load() var auto_refresh = setInterval(page_load(),5000); } </script>
- 2 replies
-
- jquery
- javascript
-
(and 1 more)
Tagged with:
-
I am running this query and the only thing i want is the title and for some reason it is giving me this. Recourse id # 7 ? Here is my query that i am running. $photo = $_GET['image']; $retrievetitle = "SELECT title FROM photo_from_user WHERE picture = '$photo' limit 1"; $title = mysql_query($retrievetitle);
-
Hi I want to submit the form automatically after sometime,. I have written the code , but its not redirecting/submitting. Don't know why.. Have a look Thanks <!DOCTYPE html> <html> <head> <script type="text/javascript"> setTimeout(function(){document.getElementById("exam").submit()},2000); </script> </head> <body> <?php date_default_timezone_set('Asia/Kolkata'); echo"Start Time: ".$starttime=date('H:i:s')."<br/><br/>"; $startstamp=time(); ?> <form action="inde x1.php" method="post" id="exam" name="exam"> Q1 Your Gender<br/> <input type="radio" value="male" name="gender"> Male <input type="radio" value="female" name="gender"> Female <br /><br /><br /> Q2 You Married<br/> <input type="radio" value="yes" name="marriage"> Yes <input type="radio" value="female" name="marriag e"> No <br /><br /><br /> Q3 2+2<br/> <input type="radio" value="4" name="add"> 4 <input type="radio" value="22" name="add"> 22 <input type="hidden" value="<?php echo $starttime; ?>" name="starttime"><br/> <input type="hidden" value="<?php echo $startstamp; ?>" name="startstamp"><br/> <input type="submit" name="submit"> </form> </body> </ html>
- 10 replies
-
Hello all, I am designing a program that consists of 1 dropdown list that pulled the value from the ORACLE DB and update the value as we change the Dropdown. I can get everything works except the submit button when we want to update the value. Please help me, I know this is a very simple problem but somehow it doesnt work. Your help with greatly appreciated. Thanks, // ASSUME CONNECTION IS DONE if (isset($_POST["ajax"]) && $_POST["ajax"] == 1) { $sql = "SELECT QTY FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $cutting_sql = "SELECT CUTTING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $assembly_sql = "SELECT ASSEMBLY FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $welding_sql = "SELECT WELDING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $drilling_sql = "SELECT DRILLING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $finishing_sql = "SELECT FINISHING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $stid = oci_parse($conn, $sql); $stid_cutting = oci_parse($conn, $cutting_sql); $stid_assembly = oci_parse($conn, $assembly_sql); $stid_welding = oci_parse($conn, $welding_sql); $stid_drilling = oci_parse($conn, $drilling_sql); $stid_finishing = oci_parse($conn, $finishing_sql); // The defines MUST be done before executing oci_define_by_name($stid, 'QTY', $qty); oci_execute($stid); oci_define_by_name($stid_cutting, 'CUTTING', $cutting); oci_execute($stid_cutting); oci_define_by_name($stid_assembly, 'ASSEMBLY', $assembly); oci_execute($stid_assembly); oci_define_by_name($stid_welding, 'WELDING', $welding); oci_execute($stid_welding); oci_define_by_name($stid_drilling, 'DRILLING', $drilling); oci_execute($stid_drilling); oci_define_by_name($stid_finishing, 'FINISHING', $finishing); oci_execute($stid_finishing); // Each fetch populates the previously defined variables with the next row's data oci_fetch($stid); oci_fetch($stid_cutting); oci_fetch($stid_assembly); oci_fetch($stid_welding); oci_fetch($stid_drilling); oci_fetch($stid_finishing); //echo quantity to the screen echo "<b><font size='10'>".$qty."</font></b></br>"; if ($cutting == $qty){ echo "<p><b><font color='#FF8566' size='5'>CUTTING COMPLETED</font></b></p>"; } else { $maxcutting = $qty - $cutting; echo "<input id='cutting' name='cutting' type='number' min = '0' max = '$maxcutting' placeholder='CUTTING PROGRESS TODAY' class='input'/>"; } if ($assembly == $qty){ echo "<p><b><font color='#FF8566' size='5'>ASSEMBLY COMPLETED</font></b></p>"; } else { $maxassembly = $qty - $assembly; echo "<input id='assembly' name='assembly' type='number' min = '0' max = '$maxassembly' placeholder='ASSEMBLY PROGRESS TODAY' class='input'/>"; } if ($welding == $qty){ echo "<p><b><font color='#FF8566' size='5'>WELDING COMPLETED</font></b></p>"; } else { $maxwelding = $qty - $welding; echo "<input id='welding' name='welding' type='number' min = '0' max = '$maxwelding' placeholder='WELDING PROGRESS TODAY' class='input'/>"; } if ($drilling == $qty){ echo "<p><b><font color='#FF8566' size='5'>DRILLING COMPLETED</font></b></p>"; } else { $maxdrilling = $qty - $drilling; echo "<input id='drilling' name='drilling' type='number' min = '0' max = '$maxdrilling' placeholder='DRILLING PROGRESS TODAY' class='input'/>"; } if ($finishing == $qty){ echo "<p><b><font color='#FF8566' size='5'>FINISHING COMPLETED</font></b></p>"; } else { $maxfinishing = $qty - $finishing; echo "<input id='finishing' name='finishing' type='number' min = '0' max = '$maxfinishing' placeholder='FINISHING PROGRESS TODAY' class='input'/>"; } echo '<section></br></br></br>'; echo ' <input type="submit" value="SUBMIT PROGRESS" class="button red" />'; echo ' <input type="reset" value="RESET FIELDS" class="button" /></br>'; echo ' <input type="button" value="GO TO PAINTING" name="paint" class="button green" /></section>'; if (isset($_POST['paint'])){ echo 'GO TO THE NEXT PAGE'; } if (isset($_POST['submit'])){ echo 'DO SUBMISSION TO THE DATABASE HERE'; } die;} ?> <!-- HTML CODE --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <title> Update Fabrication Progress</title> <link type="text/css" rel="stylesheet" href="../css/goldenform/golden-forms.css"/> <link type="text/css" rel="stylesheet" href="../css/goldenform/font-awesome.min.css"/> <script type="text/javascript"> function OnSelectionChange (select) { var selectedOption = select.options[select.selectedIndex]; //some ajax checkpoint //alert ("The selected option is " + selectedOption.value); jQuery.ajax({ url: location.href, data: {'hm':selectedOption.value, 'ajax':1}, type: "POST", success: function( data ) { jQuery("#lbl_qty").html(data);//PRINT QTY TO THE SCREEN } }); //some ajax checkpoint //alert('after ajax'); } </script> <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> </head> <body class="bg-wooden"> <div class="gforms"> <div class="golden-forms wrapper"> <form> <div class="form-title"> <h2>FABRICATION UPDATE</h2> </div><!-- end .form-title section --> <div class="form-enclose"> <div class="form-section"> <fieldset> <legend>  Select HEADMARK and the details will be shown <span class="bubble blue">1</span></legend> <section> <div class="row"> <div class="col4 first"> <label for="headmark" class="lbl-text tleft">HEADMARK :</label> </div><!-- end .col4 section --> <div class="col8 last"> <!-- POPULATED DROPDOWN LIST FROM THE DB --> <label for="headmark" class="lbl-ui select"> <?php $sql_hm_comp = 'SELECT HEAD_MARK FROM FABRICATION'; $result = oci_parse($conn, $sql_hm_comp); oci_execute($result); echo '<SELECT name="headmark" id="headmark" onchange="OnSelectionChange(this)">'.'<br>'; echo '<OPTION VALUE=" ">'."".'</OPTION>'; while($row = oci_fetch_array($result,OCI_ASSOC)){ $HM = $row ['HEAD_MARK']; echo "<OPTION VALUE='$HM'>$HM</OPTION>"; } echo '</SELECT>'; ?> </label> </div> </div> </section><!-- END OF DROPDOWN LIST --> <section> <div class="row"> <div class="col4 first"> <label for="lnames" class="lbl-text tleft">Total Quantity:</label> </div> <div class="col8 last"> <!-- VALUE PASSED FROM AJAX PROCESSING --> <label id='lbl_qty' class='lbl-ui'><font size='3'></font></label> </div> </div> </section> </div> </div> <div class="form-buttons"> </div> </form> </div> </div> <div></div> <div></div> </body> </html>
-
javascript is not looping with mysql_fetch_array result even though it showing timer on one product only .i don't know what mistake i have did ,,plz help me ,,i ma very new with php and java script..even i have taken javascript timer from google itself ..plz help me <?php $conn = mysql_connect('localhost','root',''); if(!$conn) die("Failed to connect to database!"); $status = mysql_select_db('bidding', $conn); if(!$status) die("Failed to select database!"); $result = mysql_query("SELECT * FROM bids where id"); $numrow = mysql_num_rows($result); if ($numrow == 0) { die('No record found.'); } ?> <?php while($row=mysql_fetch_array($result)){ $closedate = date_format(date_create($row['closing_date']), 'm/d/Y H:i:s'); $images_field= $row['image']; $image_show= "images/$images_field"; ?> <div class="bidbar1"> <div id="lastsold"><strong>Last Sold : ₹ </strong><?php echo $row['lastsold']; ?> </div> <div id="title"><?php echo $row['description']; ?></div> <div id="detail"><img src="image/moredetail.jpg" height="150" alt="more detail" /> </div> <div id="image"><img src="<?php echo $image_show; ?>" width="205" height="150" alt="more detail" /></div> <div id="clock"><table><tr><td style="font-size:18px;text-align:center; padding- left:30px;">Days Hr Min Sec</td></tr> <tr><td style="font-size:32px; font:bold; text-align:center;padding-left:30px;"> <script> var cdtd = function(id,end) { var start = new Date(); var timeDiff = end.getTime() - start.getTime(); if(timeDiff <=0 ) { //$('#bidbar1').remove(); //return; // alert('We have lift off!'); //$('#bidbar1').delay(50000000).fadeout(); $(window).load(function(){$('#bidbar1').remove(); }); return false; } var seconds = Math.floor(timeDiff / 1000); var minutes = Math.floor(seconds / 60); var hours = Math.floor(minutes / 60); var days = Math.floor(hours / 24); hours %= 24; minutes %= 60; seconds %= 60; $( id + " .days").html(days); $( id + " .hours").html(hours); $( id + " .minutes").html( minutes); $( id + " .seconds").html( seconds ); console.log(id + " .hoursBox",$( id + " .hoursBox").length,id,end,hours,minutes,seconds) var timer = setTimeout(function(){cdtd(id,end)},1000); } cdtd("#counter1",new Date("<?php echo $closedate; ?>")); //cdtd("#counter2",new Date("march 16, 2014 18:06:30")); //cdtd("#counter3",new Date("march 16, 2014 17:37:00")); //cdtd("#counter4",new Date("march 16, 2014 17:38:00")); //cdtd("#counter5",new Date("june 2, 2014 10:55:00")); //cdtd("#counter6",new Date("April 2, 2014 10:30:00")); //cdtd("#counter7",new Date("April 3, 2014 00:01:00")); //cdtd("#counter8",new Date("April 1, 2014 00:01:00")); //cdtd("#counter9",new Date("April 4, 2014 00:01:00")); //cdtd("#counter10",new Date("April 5, 2014 00:01:00")); //cdtd("#counter11",new Date("April 19, 2014 00:01:00")); //cdtd("#counter12",new Date("April 20, 2014 00:01:00")); </script> <div id="counter1"> <div class="box days">0</div> <div class="box hours">0</div> <div class="box minutes">0</div> <div class="box seconds">0</div> </div> </td></tr></table></div> <div id="mrp"><strong>MRP : ₹</strong><?php echo $row['mrp']; ?></div> <div id="endt"><strong>End Time: ₹</strong><?php echo $row['closing_date']; ?></div> <div id="fee"><strong>Bid Fee : ₹</strong><?php echo $row['bid fee']; ?></div> <div id="current"><strong>Current Winner</br>↓ </strong></div> <div id="buy"> <table width="271" border="0" cellpadding="0.1"> <tr> <td><img src="image/buy.png" alt="buy now" longdesc="http://buy now" /></td> <td width=110><?php echo $row['currentwinner']; ?></td> <td><img src="image/bid.png" alt="bid now" longdesc="http://bidnow " /></td> </tr> </table> </div></div> <?php } ?>