JavaScript - I Want To Create A Qr Scanner For My Iphone!?
I want to Create a simple scanner app for the iPhone so when someone scans a URL embedded in a QR code, it opens the browser and loads that URL.
Similar TutorialsHi guys, I am new to java, I am having trouble on outputting the num2 on the screen. I could not see any errors indicated the problem on the program(Eclipse). However, the program just miss scan the num2. I was trying to sort the number and output them from smallest to largest. Any suggestion would be helpful and appreciated! ----------------------------------Code import java.util.Scanner; public class Demo{ public static void main(String[] args){ System.out.println("Please input three songs' BPMs"); int S,M,L; Scanner keyboard =new Scanner(System.in); int num1 = keyboard.nextInt(); int num2 = keyboard.nextInt(); int num3 = keyboard.nextInt(); boolean isAllSame = (num1 == num2) && (num2 == num3) && (num1 == num3); boolean isDI = (num1 != num2) && (num2 != num3) && (num1 != num3); boolean isTS = (num1 != (num2 = num3)) || ((num1=num2) !=num3) || ((num1 = num3) != num2); boolean isCMatch = Math.abs(num2 - num3) < 10 && Math.abs(num2 - num1) < 10; boolean isCM2 = Math.abs(num3 - num1) < 10 && Math.abs(num3-num2) <10; boolean isCM3 = Math.abs(num1 - num2) < 10 && Math.abs(num1-num3) <10; boolean isOkMatch = Math.abs(num2 - num3) >=10 && Math.abs(num2 - num3)<=30; boolean isOM2 = Math.abs(num3 - num1) >=10 && Math.abs(num3 - num1)<=30; boolean isOM3 = Math.abs(num1 - num2) >=10 && Math.abs(num1 - num2)<=30; boolean isMismatch = Math.abs(num2 - num3) >=31; boolean isMM2 = Math.abs(num3 - num1) >=31; boolean isMM3 = Math.abs(num1 - num2) >=31; //small to largest if (num1<num2 && num1<num3 && num2<num3){ S = num1; M =num2; L =num3;} else if (num2<num1 &&num2<num3&&num1<num3){ S = num2; M = num1; L = num3;} else if (num3<num1 &&num3<num2 && num1<num2){ S =num3; M =num1; L =num2;} else{ S = num2; M = num3; L = num1; System.out.println("Sorted BPMs a "+S +","+M +","+ L); } if (isAllSame) System.out.println("Three songs have same BPMs."); else if (isDI && isCMatch){ N(); CM(); } else if (isDI && isCM3){ N(); CM(); } else if (isDI && isCM2){ N(); CM(); } else if (isTS && isCMatch){ SBMP(); CM(); } else if (isTS && isCM2){ SBMP(); CM(); } else if (isTS && isCM3){ SBMP(); CM(); } //When two song BPM larger than 10. order from all different to two same. else if (isDI && isOkMatch){ N(); OK(); } else if (isDI && isOM3){ N(); OK(); } else if (isDI && isOM2){ N(); OK(); } else if (isTS && isOM2){ SBMP(); OK();} else if (isTS && isOM3){ SBMP(); OK();} else if (isTS && isOkMatch){ SBMP(); OK();} //When some BPMs are larger than 30, Order from all different to some are same. else if (isDI && isMismatch){ N(); PM(); } else if (isDI && isMM3){ N(); PM(); } else if (isDI && isMM2){ N(); PM(); } else if ( isTS && isMM2){ SBMP(); PM();} else if ( isTS && isMismatch){ SBMP(); PM();} else if ( isTS && isMM3){ SBMP(); PM();} } public static void SBMP(){ System.out.println("\nSome are the same BMP"); } public static void N(){ System.out.println("\nNone share the same BMP"); } public static void CM(){ System.out.println("All are within 10 BPMs of eath other");} public static void OK(){ System.out.println("All are within 10 to 30 BPMs of each other.");} public static void PM(){ System.out.println("At least two songs are Possible Match");} } ------------------------------------Output Please input three songs' BPMs 15 19 50 Sorted BPMs a 50,50,15 None share the same BMP At least two songs are Possible Match Hi.. I just want to know how does it happen that when I scan the barcode using barcode scanner it will automatically put on the first textbox, then the focus will go to the next textbox and on the last textbox will automatically save the data to database. here is my sample form. PHP Code: <?php error_reporting(0); date_default_timezone_set("Asia/Singapore"); //set the time zone $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); $sr_date =date('Y-m-d H:i:s'); $sql = "SELECT sr_number FROM receiving_materials ORDER BY sr_date DESC LIMIT 1"; $result = mysql_query($sql, $con); if (!$result) { echo 'failed'; die(); } $total = mysql_num_rows($result); if ($total <= 0) { $currentSRNum = 1; $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } else { //------------------------------------------------------------------------------------------------------------------ // Stock Number iteration.... $row = mysql_fetch_assoc($result); $currentSRNum = (int)(substr($row['sr_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); ?> <html> <title>Receiving Materials</title> <head> <link rel="stylesheet" type="text/css" href="kanban.css" /> <style type="text/css"> #SR_date{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } </style> </head> <body> <form name="receiving_form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div id="SR_date"> <label>Date :</label> <input type="text" name="sr_date" value="<?php echo $sr_date; ?>" size="16" readonly="readonly" style="border: none;"> </div> <div id="SR_number"> <label>RM# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="9" readonly="readonly" style="font-weight: bold; border: none;"> </div> <div id="SI_number"> <label class="LLabelRM">SI/DR# :</label> <input type="text" name="si_num" id="si_num" class="LFieldRM" value="" size="25"> <br/></br/> <label class="LLabelRM">Supplier Name :</label> <input type="text" name="s_name" id="s_name" class="LFieldRM" value="" size="25"> <br/></br/> <label class="LLabelSecRM">PO # :</label> <input type="text" name="po_num" id="po_num" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">Quantity :</label> <input type="text" name="qty" id="qty" class="LFieldSec1RM" value="" size="25"> <br/> <br/> <label class="LLabelSecRM">Material Code :</label> <input type="text" name="mat_code" id="mat_code" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">Material Desc. :</label> <input type="text" name="mat_desc" id="mat_desc" class="LFieldSec1RM" value="" size="25"> <br/></br/> <label class="LLabelSecRM">WH Code :</label> <input type="text" name="wh_code" id="wh_code" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">BIN Location :</label> <input type="text" name="bin_loc" id="bin_loc" class="LFieldSec1RM" value="" size="25"> </div> </form> </body> </html> Thank you I am trying to create a mobile safari compatible "slide to unlock" type deal, like the one on jailbreakme.com, i have found many that are compatible with google chrome, or firefox, but none with mobile safari, any help?
Hi Guys. Trying to pass variables from the javascript into my php script and into my SQL query so i can track the location of the iphone. So far i have... Code: <script type="text/javascript"> function getGPS() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showGPS, gpsError); } else { gpsText.innerText = "No GPS Functionality."; } } long = position.coords.longitude; lat = position.coords.latitude; function gpsError(error) { alert("GPS Error: "+error.code+", "+error.message); } function showGPS(position) { gpsText.innerHTML = "<?php $long = "".$_GET['long'].""; $lat = "".$_GET['lat'].""; $sqldel = "INSERT INTO `location` (`id` ,`user_id` ,`long` ,`lat`) VALUES (NULL , '$user', '$long','$lat' );"; mysql_query($sqldel) or die(mysql_error()); echo "$long"; echo "$lat"; ?>"; } </script> This gets the coordinates in javascript and the php runs and i get a new record in the database but it doesnt pass the variables from java to php. Anyone know a workaround to get the variables from the iphone to sql on a single page? I want this to run in the background and refresh every now and then so i can track users location. thanks. Adam. This is for an iphone app using html5, css3 and javascript with phonegap to embed. The app runs on mobile safari. I have a list page [ list.html ] . Clicking on a list item takes the user to a specific page for that item [ e.g. item1.html ]. On item1.html page a question is answered in a form box. This is processed using a simple pasuser script which works fine. I need to add a script so that when a correct answer is given on item1.html a small graphic appears next to to the item listed on list.html. Even though item1.html can be accessed again later, the small graphic must always remain next to the listing. All help much appreciated. I am not a programmer but can understand the arguments. Thanks. hi, I am trying to redirect from my main site to my mobile site by detecting screen width using javascript. But everything time i try to test this via the iphone 4s,the browser keeps reloading without loading any content, like its on some sort of loop! Here are the scripts ive tried to used below, have i missed anything? [CODE] <script type="text/javascript" charset="utf-8"> if (navigator.userAgent.match(/(operamini|ipad|ipod|iphone|android|webOS|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafon e|o2|pocket|kindle|mobile|hiptop|\bpda|psp|treo|nokia|blackberry)/i)) { location.replace("example.com"); } </script> [CODE END] [CODE] <script type="text/javascript"> if (screen.width <= 550) window.location = 'http://yoursite.com/mobile'; </script> [CODE END] Thanks in advance for any help! Jon I've put together a couple of scripts, in order that I can make an image move left or right on the x-axis, depending on the LR (left/right) read-out from the accelerometer of an iPhone. However, it's not working at the moment, so could anyone possibly see what I've missed out - I've worked on it that long, that I think I'm missing something obvious!! THANKS!! Code: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>onlywebpro.com</title> </head> <body> <h2>Device Orientation with HTML5 | onlywebpro.com</h2> <img src="Car4.png" id="car" style="position:relative;top:200px;left:200px; "><br> <script type="text/javascript"> if (window.DeviceOrientationEvent) { console.log("DeviceOrientation is supported"); window.addEventListener('deviceorientation', function(eventData) { var LR = eventData.gamma; deviceOrientationHandler(LR); var userWidth = window.screen.width; function moveRight() { var pp = document.getElementById("car"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveRight()",50); // 50 controls the speed lft = lft+LR; // move by 50 pixels pp.style.left = lft+"px"; if (lft > userWidth + 439) { // left edge of image past the right edge of screen pp.style.left = -400; // back to the left clearTimeout(tim); } } }, false); } else { alert("Not supported on your device or browser. Sorry."); } var userWidth = window.screen.width; function moveRight() { var pp = document.getElementById("car"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveRight()",50); // 50 controls the speed lft = lft+LR; // move by 50 pixels pp.style.left = lft+"px"; if (lft > userWidth + 439) { // left edge of image past the right edge of screen pp.style.left = -878; // back to the left clearTimeout(tim); } } </script> </body> </html> Hi On the following URL on the iphone and Ipad the jqzoom script is showing the enlarged image on the left but works fine in IE, Chrome, Firefox etc. The script in use is jqzoom. http://tinyurl.com/bwcxf8c Any idea welcome. Thanks Roy Hi Guys, I've been searching the net for both examples and pluggins to create draggable divs and although I've found many, I cant find the effect I'm after. I want the div to slow down to a stop after it has been release like when you are scrolling on one of apples mobile devices. If anybody can point me in the right direction ill be very great full. I'm working on this project: http://bit.ly/tkrFsP It already works more or less fine in: IE7, IE8, IE9, FF, Chrome, Safari and Opera. Problems start when we try that in iPhone or iPad. iPhone works almost fine (except lags and AJAX/jQuery problems) but in iPad it has broken left navigation, wrongly re-sized thumbnails and it displays in half of the viewport. Also, there are problems with smoothness of jQuery animations and with AJAX unlike in other browsers on other devices (like PC). Any ideas on how to fix that? I've flicked through this: 1. http://www.smashingmagazine.com/2010...tting-started/ 2. http://developer.apple.com/library/s...62/_index.html It seems like a good place to start but there's many information on iPad/iPhone development on apple.com and their solutions don't fix my problems. -------- Mo 1. Anyone could outline here some basic code principles for iPad/iPhone? 2. Why project sub-page displays 5 times as large as it should on iPhone? Adding this: <meta name="viewport" content="width=device-width" /> doesn't help much and it even makes website work worse. Adding this: <meta name="viewport" content="maximum-scale=1,user-scalable=yes,width=960" > seems like a better solution but it's not perfect either. 3. How iPad's fixed containers work? 4. Why there's horizontal scroll appearing even with overflow-x: hidden? I have a simple play js button on my HTML page as well as embedded music. So when you are a computer the music autoplays then stops and you have the option to listen to it again with the js button. This "theoretically" will work fine for the iPhone and iPad because even though the embedded music isn't auto playing the user can still click the listen button and hear the music. It works on the iPhone perfectly but not the iPad. I'm at a loss. Here is my jscript: function FFFFSound(soundobj) { var thissound= eval("document."+soundobj); thissound.Play(); } My embedded music: <embed src="music/FFFFKids.mp3" autostart="true" loop="false" hidden="true"> <embed src="music/FFFFKids.mp3" autostart="false" loop="false" hidden="true" name="sound1"> And my button: <input type="button" value="Listen" onClick="FFFFSound('sound1')" class="listen_button"> You can view the page at feefifofun.com I am at a total loss..... thanks! hi, When I navigate to a page with Ajax on my iphone or ipad, it doesn't show up, page is just blank, I have checked for errors and there is no errors?! here is my Ajax code Code: function datecheckFunction(){ var datecheckRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari datecheckRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ datecheckRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ datecheckRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server datecheckRequest.onreadystatechange = function(){ if(datecheckRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = datecheckRequest.responseText; } } var datepicker = document.getElementById('datepicker').value; var queryString = "?datepicker=" + datepicker; //Add the following line datecheckRequest.open("GET", "http://www.affordableappliancerepairs.co.uk/admin/checkdate.php" + queryString, true); datecheckRequest.send(null); } I have a video on a page, which on a pc or mac, will play inside a standard flash player. On the iphone, I have setup javascript to detect iphone / ipod, and replace the flash player with an embedded m4v file: Code: if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { $('div#vid').empty(''); $('div#vid').html('<div ontouchstart="incrementHitcount()"><embed src="http://www.gridcity.co.nz/uploaded/images/'+cid+'_bg.jpg" href="http://www.gridcity.co.nz/uploaded/videos/'+cid+'.m4v" type="video/x-m4v" rel="nofollow" target="myself" width="'+vidwidth+'" height="'+vidheight+'" scale="1" id="iphone"></embed><div>'); } So far so good. I also want to trigger a simple onclick which makes an ajax call a remote PHP file. I have tried ontouchstart instead (see above code) but still no luck. If I add the onclick to a static image rather than an embed instance, it works fine. But with the embedded video, it's as if the video blocks the onclick event for javascript to pickup. Does anyone know a way around this? Hello I'm having problems with a very simple bit of Javascript not working with the latest version of Safari for ipads and iphones. The script in question is used as a 'previous image ' and 'next image' navigation facility, basically closing one pop-up window and opening up another, when viewing a photo gallery. It has worked perfectly for a number of years on all browsers. It is only the latest version of Safari for ipads and iphones where there's a problem. On an iphone, the new window unfortunately opens up in a new tab and the existing window fails to close. Mobile Safari soon reaches the maximum of 8 permissible tabs as a user moves through the photos gallery. On an ipad2, no new window opens and the existing window fails to close. the website is www.gethigh.co.uk Code: } function picPopup4(page,width,height){ //alert(scroll); var a; a = width / 2; var b; b = height / 2; var LeftPosition = (screen.width/2) - a; var TopPosition = (screen.height/2) - b; window.open(page, "", "width="+width+",height="+height+",toolbar=no,header=no,location=no,resizable=yes,"+"left="+LeftPosition +",top="+TopPosition+",scrollbars=yes"); window.close(); } and this is an example of the code creating the navigation within each pop-up window Code: <tr> <td align="center"><a class="link8" href="javascript:picPopup4('legslip1.html','560','770');" target="_self"> previous image</a> <a class="link8" href="javascript:window.close()">close window</a> <a class="link8" href="javascript:picPopup4('breaking2.html','505','800');" target="_self">next image</a></td> </tr> I'll come clean and admit I'm not a programmer and have a very basic and ancient understanding of HTML coding. My website must be approaching double digit years old (which will be immediately apparent if you view its structure). I can usually resolve most things, and maintain its functioanality when needs be, but this particular problem has got me stumped. I've come onto this forum to see if anyone could provide a simple work-around ? Or if anyone would know if this is a bug within Safari which may be rectified soon (a search through the Apple forums gave no clues). I'm loathed to make any major updates/changes to my site, as despite its age it renders beautifully on all browsers except the latest ipad/iphone Safari. Cheers and hopefully thanks in advance Garry .... How can i create an image rotator just like in redtube.com. When mouseenter it changes the img's src. When mouseleave it returns the default src. Ps: sorry abou the website font.hehe hello friends.. I am working on the html code in which i using the List Control The Requirement that among the List element in which I choose the locations there is option in which whenever i select the option None From The List then it should Disply the empty textbox So how the function is declared Please tell me... I am trying to create a basic javascript that shows milage between severag areas, similar to what you find on the rear road atlas. I have tried and failed to create anything, i just think i am total useless at understanding javascript. The basic concept is this image attached. There would be a drop down box that lists the destinations and another with the same but would be departure. When a person chooses example: Butte >>> Kalipsell it would show 238 and vice versa. it seems a simple thing to do but cant get my head around it all. Could someone create a simple script, say 3 destinations and i will fill the rest in and see if i can understand what i am doing and then ask for additional help if required? Hi all Not sure how to tackle this. I haven't done any DOM manipulation and this is a tag within a tag. Another thing is submit is Ajax and therefore can be hit many times --- so I guess I need to also check if element already exists. The result comes back from PHP and I think wipes out anything in the result area. I want to create this: Code: <span id="loading"><img src="loading.gif" /></span> Code: <div id="results">which should populate here</div> <script type="text/javascript"> function loading(){ ? </script> <input type="button" name="submit" id="submit" onclick="loading();"/> How do I begin this? Help appreciated. LT oh this is my Ajax just in case what i'm trying to do should be done from here. Code: <script type="text/javascript"> $(document).ready(function() { $('#submit').click(function(){ //Get the values var amount = $('#amount').val(); var from = $('#from').val(); var to = $('#to').val(); var params = "amount=" + amount + "&from=" + from + "&to=" + to; $.ajax({ type: "POST", url: "change.php", data: params, success: function(data){ $('#results').html(data).fadeIn("slow"); } }); }); }); </script> I have a select with a OnChange Function. I would like to know how to create a different object depending on the selection on the Select. Example: MySelect have Option 1 and Option 2, so If (Myselect.value == Option 1) {Create Object 1} If (Myselect.value == Option 2) {Create Object 2} I'm using the object under <body> and it's working, but when I'm trying to use it under a <script> does not work. This is the object I'm trying to create: (It is a map) so what I'm trying is to change the values or map depending on the selection of the Select. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="900" height="600" id="zoom_map" align="top"> <param name="movie" value="us_albers.swf?data_file=senate.xml" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <embed src="us_albers.swf?data_file=senate.xml" quality="high" bgcolor="#FFFFFF" width="100" height="100" name="Clickable U.S. Map" align="top" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed> </object> Thank you very much Hi I wanted to create multiple check box and once check box is clicked user should able to enter text and submit so i created this but when check box toggle it keep creating text areas. i wanted to create 1 text area per one check box also i need to store each text area value to data base. how can i correct this to achieve my needs PHP Code: <script type="text/javascript"> function validate(chk){ if (chk.checked == 1){ var htmlText = "<textarea name='area' cols='40' rows='5'></textarea>"; var newElement = document.createElement('div'); newElement.id = 'text'; newElement.innerHTML = htmlText; var fieldsArea = document.getElementById('text'); fieldsArea.appendChild(newElement); }else {} } </script> <form> <label>option1 <input type=checkbox name=chk1 onclick="return validate(chk1);"></label> <label>option2 <input type=checkbox name=chk2 onclick="return validate(chk2);"></label> </form> <div id="text"></div> Sorry for the language errors Regards. |