Craig Hopson
-
Posts
212 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Craig Hopson
-
-
Thanks for the reply but that does'nt work with my code i dont need to hid a div just the table cells
-
Hi guys using this code to hide table contents but how can i make the table hidden on page load
$('.header').click(function () { var $this = $(this); $(this).nextUntil('tr.header').slideToggle(100).promise().done(function () { $this.find('span').text(function (_, value) { return value == '-' ? '+' : '-' }); });});
Thanks
-
Any errors in the console?
do you have control over the backend? It seems like there's an extra layer of nesting. I would expect a flatter object being returned, something like
{ prop1: 23.375 prop2: 23.5}
it is coming from here
#!/usr/bin/pythonimport sys, json, oslist = os.listdir("/sys/bus/w1/devices/")list.remove("w1_bus_master1")# we can also build lists, first start with an empty oneoutput = []for sensor in list: # Open the file that we viewed earlier so that python can see what is in it. Replace the serial number as before. tfile = open("/sys/bus/w1/devices/" + sensor + "/w1_slave") # Read all of the text in the file. text = tfile.read() # Close the file now that the text has been read. tfile.close() # Split the text with new lines (n) and select the second line. secondline = text.split("n")[1] # Split the line into words, referring to the spaces, and select the 10th word (counting from 0). temperaturedata = secondline.split(" ")[9] # The first two characters are "t=", so get rid of those and convert the temperature from a string to a number. temperature = float(temperaturedata[2:]) # Put the decimal point in the right place and display it. temperature = temperature / 1000 #print temperature output.append({ sensor:temperature })# Send it to stdout (to PHP)out = json.dumps(output,separators=(',', ':'))print out
output for this is [{"prob2":23.75},{"prob1":23.625}]
-
Hi guys my JS is poor at best i have this
[Object { prob2=23.5}, Object { prob1=23.375}]
showing in my console.log it comes from a AJAX request from PHP i'm getting this out put by this
$.ajax({ url:"temps.php", dataType: "json", success:function(data) { console.log(data); }
how can i use thi information like this???
$.ajax({ url:"temps.php", dataType: "json", success:function(data) { document.getElementById("prob1").innerHTML = data.prob1; }
Please help cos this dont work lol
Thanks
-
i dont understand this is dropdown menus not selection boxes
-
Hi guys, what i am looking for is 5 drop down boxes with 5 options.
When one option is selected it then cant be selected in the other 4 drop downs and so on until eventually all 5 drop downs will have one off the 5 options
i'm using bootstrap (hence posting in Javascript section), I'm shore there is a easy way to do this i just cant figure it out
Thanks all
-
Hi guys i'm prob going about this the wrong way but this is what i have so farThe HTML
<div class="example"> <input type="radio" value="border-0" name="Border" id="text1" checked="checked"/> No Border </div> <div class="border-1 example"> <input type="radio" value="border-1" name="Border" id="text2" /> Single Line </div> <div class="border-2 example"> <input type="radio" value="border-2" name="Border" id="text3" /> Double Line </div> <div class="border-3 example"> <input type="radio" value="border-3" name="Border" id="text4" /> 3D Line </div> <div class="font-1 example"> <input type="radio" value="font-1" name="Font" id="text1" checked="checked"/> Normal Font </div> <div class="font-2 example"> <input type="radio" value="font-2" name="Font" id="text2" /> Font 2 </div> <div class="font-3 example"> <input type="radio" value="font-3" name="Font" id="text3" /> Font 3 </div> <div class="font-4 example"> <input type="radio" value="font-4" name="Font" id="text4" /> Font 4 </div><span id="regdisplay" class="">HELLO</span>
The JS$(function() { $('[name=Border]').click(function() { var classy = $(this).val(); $('#regdisplay').removeClass(); if($(this).is(':checked')) { $('#regdisplay').addClass(classy); } });});$(function() { $('[name=Font]').click(function() { var fonty = $(this).val(); $('#regdisplay').removeClass(); if($(this).is(':checked')) { $('#regdisplay').addClass(fonty); } });});
The problem i have is once you selected the border and it has been applied to #regdisplay you then select a font but it will removeClass for the border.What i was thinking was removeClass(border-????) or removeClass(font-????) but not shore how or maybe i'm going about this all wrong.so help please.P.S. Please excuse the formatting. -
WAIT A MIN... i dont understand arrays fully but it it right that...first
array([color=#ff0000]1[/color]) { ["notifications"]=> array([color=#ff0000]2[/color]) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" }}
and
array([color=#ff0000]4[/color]) { ["notifications"]=> array([color=#ff0000]2[/color]) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" } ["friends"]=> array([color=#ff0000]2[/color]) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" } ["messages"]=> array([color=#ff0000]2[/color]) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" } ["search"]=> array([color=#ff0000]2[/color]) { ["pos_left"]=> string(2) "20" ["pos_top"]=> string(2) "20" }}
the highlited RED numbers in the arrays is this correct??? [EDIT]--WHY color=#ff0000 INSTEAD OF RED??
-
ok so i have tried debugging and all results work just fine untill i change 4 items then it restarts the array, So how about if i change it so onunload it saves positions off the divs?? would this be a better option?
-
WHOOPS miss type i will correct that....How would you go about debuging this?I'm curious why you're looking for records where the user ID is greater than or equal. -
hi guys i have a problem and here it is i am makeing a website with draggable boxs lik this
$(function () { $(".draggable").draggable({ containment: '#holder', grid: [ 20, 20 ], handle:'.box-header', cursor: 'move', stop : function(event,ui) { var dragposition = ui.position; var dragboxid = $(this).attr('id'); $.ajax({ type: 'POST', dataType: 'json', url: My_Site+'/themes/mytheme-2/ajax.php', timeout: 5000, data: { task:"Moved", dragposition:dragposition, user_id:User_ID, dragboxid:dragboxid } }); } });});
as you can see when you finish moving the box it will log the position with AJAX here is the "ajax.php" file
if($_POST['task'] == 'Moved'){$dragboxid = $_POST['dragboxid'];$dragposition_left = $_POST['dragposition'][left];$dragposition_top = $_POST['dragposition'][top];$uid = $_POST['user_id'];$exist = mysql_query("SELECT var1 FROM `jcow_mytheme` WHERE uid >= '$_POST[user_id]' LIMIT 1");if(mysql_num_rows($exist) == 0){ $var1[$dragboxid] = array("pos_left"=>$dragposition_left,"pos_top"=>$dragposition_top); $var1e = serialize($var1); mysql_query("INSERT INTO `".$table_prefix."mytheme` (uid, var1) VALUES('$uid', '$var1e' ) "); }else{ $row = mysql_fetch_array($exist); $var1d = unserialize($row['var1']); $var1d[$dragboxid] = array("pos_left"=>$dragposition_left,"pos_top"=>$dragposition_top); $var = serialize($var1d); mysql_query("UPDATE `".$table_prefix."mytheme` SET var1='$var' WHERE uid='$_POST[user_id]'"); }}
this all works GREAT, but only once, the second time it wipes the array and starts again i will post some of the array to show my problemfirst time
array(1) { ["notifications"]=> array(2) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" }}
second time
array(2) { ["notifications"]=> array(2) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" } ["friends"]=> array(2) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" }}
Forth time
array(4) { ["notifications"]=> array(2) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" } ["friends"]=> array(2) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" } ["messages"]=> array(2) { ["pos_left"]=> string(1) "0" ["pos_top"]=> string(2) "20" } ["search"]=> array(2) { ["pos_left"]=> string(2) "20" ["pos_top"]=> string(2) "20" }}
and the wierd one Fifth one
array(1) { ["new_member"]=> array(2) { ["pos_left"]=> string(3) "-20" ["pos_top"]=> string(2) "20" }}
HELP PLEASE lolthanks guys
-
hi guys i am having trouble with the syntax of a query here is what i have not shore where to go from here
select * from `jcow_accounts` WHERE 1 AND (username LIKE craig% OR email LIKE craig% OR fullname LIKE craig%) AND birthyear>1953 AND birthyear<1995 AND gender=0 and !hide_me order by lastlogin DESC LIMIT 20
Thanks
-
oh i see thanks ill have a look
-
click settings to get back to form saying that it still logged your location
-
hi all new day new problem... ok i THINK the problem i'm having is memory leak but not shore. my script logs user location as they move, if you look at http://chsites.co.uk/track/www/index.html Tracking ID = 97Send at most every (sec) = 5Minimum Accuracy (meters) = 100000 then open your debug console (i have some notes in there still debugging) you will see that it logs every 5 seconds all good it works BUT after some time it will lock up the browser and eventually crash italso problem 2 it will post multi times like 3 times at once how can i stop that so to recap...problem 1:- browser locking up after some time.problem 2:-multi posting. Thanks
-
how? SOLVEDAt first glance I would say that the form is submitting and reloading the page. You should cancel the submission in the submit handler.<form method="post" data-ajax="false" onSubmit="LogID(this);return false;">
-
hi i wish to get a variable from the form (page1) onsubmit switch to (page2) and display value here is what i have but i cant get it to work, i get the "alert(Device_ID); " all fine but wont redirect
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="format-detection" content="telephone=no" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="css/jquery-mobile.css" /> <script type="text/javascript" src="js/cordova-2.2.0.js"></script> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-mobile.js"></script> <title>CHTracker</title><script>function LogID(Form) {var Device_ID = Form.tracking_ID.value; alert(Device_ID);$.mobile.changePage( "#page2", { transition: "slideup"} ); }</script> </head> <body> <!-- Start of second page --><div data-role="page" id="page1"><div data-role="header"> <h1>CHTracker</h1></div><!-- /header --><div data-role="content"> <p>Please enter tracking ID:-</p> <p> <form method="post" data-ajax="false" onSubmit="LogID(this);"> <div data-role="fieldcontain"> <label for="tracking_ID">Tracking ID:-</label> <input type="text" name="tracking_ID" id="tracking_ID" /> </div> <input type="submit" value="Login" /> </form> </div><!-- /content --><div data-role="footer" data-position="fixed"> <h4>Page Footer</h4></div><!-- /footer --></div><!-- /page --><!-- Start of second page --><div data-role="page" id="page2"><div data-role="header"> <h1>CHTracker</h1></div><!-- /header --><div data-role="content"> <p>SOMETRACKING</p> </div><!-- /content --><div data-role="footer" data-position="fixed"> <h4>Page Footer</h4></div><!-- /footer --></div><!-- /page --> </body></html>
-
just update the existing one i thing i've found something its panTo() i thing i need to use this
-
sorry looking back i was vague. OK a simple Google map API V3 would be HTML
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC9drFQnsmuob_bO9wFITHv-5K2pM-lgD0&sensor=false"></script> <script type="text/javascript">var map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(LATITUDE,LONGITUDE), //THIS MUST BE A POSITION (you understand) zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR }, navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL } });</script>
OK this will show a map with the center of the map whatever LATITUDE,LONGITUDE you put in i wish to update the map center every 10 seconds with new coordinates (the script in first post)
-
hi can some one check this syntax of this cos i'm missing something it just dont workThe JS
downloadUrl("http://chsites.co.uk/track/inc/maploc.php?id='.$mapid.'&name='.$member['id'].'", function(data) {var xml = data.responseXML; var Center = xml.documentElement.getElementsByTagName("marker"); var map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng( parseFloat(Center.getAttribute("lat")), parseFloat(Center.getAttribute("lon"))), zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR }, navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL } });} function downloadUrl(url, callback) { var request = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest; request.onreadystatechange = function() { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request, request.status); } }; request.open("GET", url, true); request.send(null); }
The XML
<markers> <marker lat="51.5589355" lon="0.1463353" speed="1.255" time="17:12:39 - 2012/12/04"/></markers>
-
can this be done?
<!DOCTYPE html><html><head><script>var seconds = 1000; function test(optvalue) { var seconds = optvalue; alert(optvalue); } window.setInterval(function(){ var d=new Date();document.getElementById("output").innerHTML = d; }, seconds);</script></head><body><select name="menu" onchange="test(this.value);"> <option value="1">1</option> <option value="5">5</option> <option value="10">10</option></select><div id="output"></div></body></html>
-
thanks easy when i look at it but i'm learning thanks for the quick response
-
hi guys can someone tell me where im going wrong please
<!DOCTYPE html><html><head><script>function test() { alert(menu1.value);}</script></head><body><select name="menu" onchange="test(menu.value);"> <option value="1">1</option> <option value="5">5</option> <option value="10">10</option></select></body></html>
-
ok i got it
<!DOCTYPE html><html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Google Maps - Moving point along a path</title> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script></head><body onunload="GUnload()"> <div id="map_canvas" style="width: 1000px; height: 800px;"></div> <script type="text/javascript"> var map; var mapOptions = { center: <?php $result = mysql_query("SELECT * FROM location ORDER BY id DESC LIMIT 1");while($row = mysql_fetch_array($result)){echo 'new google.maps.LatLng('.$row['latitude'].', '.$row['longitude'].'),';}?> zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP }; function initialize() { map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);var userCoor = [ <?php $result = mysql_query("SELECT * FROM location ORDER BY id DESC LIMIT 30");while($row = mysql_fetch_array($result)){echo '["'.$row['id'].'<br>'.$row['time'].'",'.$row['latitude'].', '.$row['longitude'].'],';} ?> ];var userCoorPath = [ <?php $result = mysql_query("SELECT * FROM location ORDER BY id LIMIT 30");while($row = mysql_fetch_array($result)){echo 'new google.maps.LatLng('.$row['latitude'].', '.$row['longitude'].'),';} ?> ]var userCoordinate = new google.maps.Polyline({path: userCoorPath,strokeColor: "#FF0000",strokeOpacity: 1,strokeWeight: 2});userCoordinate.setMap(map);var infowindow = new google.maps.InfoWindow();var marker, i;for (i = 0; i < userCoor.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(userCoor[i][1], userCoor[i][2]), map: map }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(userCoor[i][0]); infowindow.open(map, marker); } })(marker, i));} } google.maps.event.addDomListener(window, 'load', initialize); </script></body></html>
Jquery auto hide
in JavaScript
Posted
ok got it just added "display:none" to the cell tags