JavaScript - Noob Question: Javascript, Google Search Api & Html
Hi all,
I'm desperately trying to figure out how to "transform" Javascript commands into HTML code. Excuse my noobness but I really know nothing about Javascript. Basically, I have this Google API Search code: Code: <!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"> <head> <title>My Google AJAX Search API Application</title> <script src="http://www.google.com/jsapi?key=CUT"></script> <script language="Javascript" type="text/javascript"> //<![CDATA[ google.load("search", "1"); function OnLoad() { // Create a search control var searchControl = new google.search.SearchControl(); // Add in a full set of searchers var localSearch = new google.search.LocalSearch(); searchControl.addSearcher(localSearch); searchControl.addSearcher(new google.search.WebSearch()); searchControl.addSearcher(new google.search.VideoSearch()); searchControl.addSearcher(new google.search.BlogSearch()); // Set the Local Search center point localSearch.setCenterPoint("New York, NY"); // Tell the searcher to draw itself and tell it where to attach searchControl.draw(document.getElementById("searchcontrol")); // Execute an inital search searchControl.execute("Google"); } google.setOnLoadCallback(OnLoad); //]]> </script> </head> <body> <div id="searchcontrol">Loading...</div> </body> </html> Now, what I'm desperately trying to do since 4-5 hours is to have the search results between the <div id="searchcontrol"></div> encoded as HTML in the loaded page. Currently, when the page is loaded and I look at the source code, I have the word 'Loading...' in the <div> tags, despite in the normal view there are G results listed. I need those results encoded as HTML for SEO reasons. Researching on this matter I thought the problem could be the OnLoad command, that makes the script load after all the other HTML elements are loaded. But I tried to make it load before all the elements in the page, and the problem persists. How can I solve this? Thanks in advance for any help! Similar TutorialsHi all, I sincerely apologise for the noob question. I have search and searched for an answer but to no avail, so I hope someone on here can help. I'm trying to get a fisheye verticle menu working. I've found somethin which fits the requirement he http://zendold.lojcomm.com.br/ifisheye/ and tried to make it work. It just doesn't. I've tried different versions of mootools etc but I think I'm missing something really stupidky simple. I'd really appreciate it if someone could have a look at my temp page (http://www.parkerbs.com/home1.htm) and point me in the right direction. Many thanks in advance. Paul I have a page with a GoogleMap with a GoogleBar and I would like the GoogleBar to appear with something written in it already and to have that search executed. In other words, I would like to "write something to the GoogleBar and press Enter" automatically as soon as the map loads. How can I do this? btw: By GoogleBar, I mean the search bar that appears on the map after using the enableGoogleBar() function. Can anyone give me some advice on how to manipulate Google Fusion Table using Javascript??? I've read the Fusion table's Developer Guider. But still feel confused. Can anyone tell me the specific solution?? Or give me a sample code?? Thanks very much!!!!!! This example works fine to match a users input. Code: if ((word[0]=="my") && (word[1]=="name") && (word[2]=="is") && (input.search(/(john|paul|zack)/)!=-1) && (num_of_words== 4)) {document.result.result.value = "Well, nice to meet you "+word[3]+"."; return true;} However, can you do a search on what would be word[3] in the example above. Something like: word[3]=="(input.search(/(john|paul|zack)/)!=-1)" Thanks! I have noooo idea if I am even posting this in the correct area, let alone the correct site. If not I apologize and maybe someone could direct me elsewhere. I am trying to add a custom search into my site. http://www.jeffknowsloans.com you can see it about the middle of the page. I am using the following script to do so. Code: <script type="text/javascript"> function dosearch() { var sf=document.searchform; var submitto = sf.sengines.options[sf.sengines.selectedIndex].value + escape(sf.searchterms.value); window.location.href = submitto; return false; } </script> <form name="searchform" onSubmit="return dosearch();"> Select County <select name="sengines"> <option value="http://www2.co.washington.mn.us/opip/mod/addresssrch/result.asp?housenum=&street=" selected>Washington</option> <option value="http://rrinfo.co.ramsey.mn.us/public/characteristic/PropertySearchResults.aspx?pin=&Nbr=&Street=&pg=1" selected>Ramsey</option> <option value="http://www.altavista.com/web/results?q=">Alta Vista</option> <option value="http://www.dogpile.com/info.dogpl/search/web/">Dogpile</option> </select> Street Address: <input type="text" name="searchterms"> <input type="submit" name="SearchSubmit" value="Search"> </form> here is the problem i am running into. I dont know how to ignore or add certain parts of the search when it sends. for example. take a look at Code: <option value="http://rrinfo.co.ramsey.mn.us/public/characteristic/PropertySearchResults.aspx?pin=&Nbr=&Street=&pg=1" selected>Ramsey</option> When i try to do a search under this drop down selection it doesnt work. because it needs the &pg=1 to be added to the users search request. Meaning if I set it to Code: http://rrinfo.co.ramsey.mn.us/public/characteristic/PropertySearchResults.aspx?pin=&Nbr=&Street= they type in their street name and the street name inputs into the search query but it wont fully work because it doesnt add the &pg=1 after it all. how in the world do I get it to add things like that? ie how do i tell it to add certain strings that the outside source requires? like blank=&blank= or how do i get it to ignore certain &blank= commands. another example taking a look at Code: <option value="http://www2.co.washington.mn.us/opip/mod/addresssrch/result.asp?housenum=&street=" selected>Washington</option> this search function should technically be Code: <option value="http://www2.co.washington.mn.us/opip/mod/addresssrch/result.asp?" selected>Washington</option> however since i dont know how to add certain functions to the search i have to skip the housenum option. that means my customers cant search by street number. I want them to be able to type in their house number and their street address and it will change to what each seperate (outside) search engine needs. Does this make any sense at all? I have put this together and it looks to me like it should work but when i ht submit it does nothing, no error or anything, which makes it hard for me to diagnose. You all are much more experienced minds and may look at it and see my error right away (at least thats what im hoping) the point of this project is a form that will post(including pics) to a google spreadsheet. it may be i need to post this in the ajax forum, but its at least partially js so let me know thank you so much for your help all Code: <!DOCTYPE html> <html> <head> <title>QC Observation</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> </head> <body> <div> <form id="form" target="_self" onsubmit="" action=""> <div class="ss-header-image-container"><div class="ss-header-image-image"><div class="ss-header-image-sizer"></div></div></div> <div class="ss-top-of-page"><div class="ss-form-heading"><h1 class="ss-form-title" dir="ltr">QC Observation</h1> <div class="ss-form"><form action="https://docs.google.com/forms/d/1jkIpSFH16SiNlsj13cBBRsuoiXmqeGVAI6PttCQiff8/formResponse" method="POST" id="ss-form" target="_self" onsubmit=""><ol role="list" class="ss-question-list" style="padding-left: 0"> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-item-required ss-select"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_1344879795"><div class="ss-q-title">Bldg <label for="itemView.getDomIdToLabel()" aria-label="(Required field)"></label> <span class="ss-required-asterisk" aria-hidden="true">*</span></div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <select name="entry.1344879795" id="entry_1344879795" aria-label="Bldg " aria-required="true" required=""><option value=""></option> <option value="A Residence">A Residence</option> <option value="B Residence">B Residence</option> <option value="C Residence">C Residence</option> <option value="D Residence">D Residence</option> <option value="OSB">OSB</option> <option value="MNT">MNT</option> <option value="TWB">TWB</option> <option value="VP">VP</option> <option value="VM">VM</option> <option value="Site Dev">Site Dev</option></select> <div class="required-message">This is a required question</div></div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-item-required ss-select"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_1358292836"><div class="ss-q-title">QC Representative <label for="itemView.getDomIdToLabel()" aria-label="(Required field)"></label> <span class="ss-required-asterisk" aria-hidden="true">*</span></div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <select name="entry.1358292836" id="entry_1358292836" aria-label="QC Representative " aria-required="true" required=""><option value=""></option> <option value="David Bradley">David Bradley</option> <option value="Ryan Harper">Ryan Harper</option> <option value="Herschell Mirick">Herschell Mirick</option> <option value="Bill Bejelis">Bill Bejelis</option> <option value="Nick Pappas">Nick Pappas</option> <option value="Stephen Gehrlich">Stephen Gehrlich</option> <option value="Beth Davis">Beth Davis</option> <option value="Ohene Akrofi">Ohene Akrofi</option> <option value="Mike Dow">Mike Dow</option> <option value="David Picknell">David Picknell</option> <option value="Lynne Viescas">Lynne Viescas</option></select> <div class="required-message">This is a required question</div></div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-item-required ss-select"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_895392494"><div class="ss-q-title">Shop Responsible <label for="itemView.getDomIdToLabel()" aria-label="(Required field)"></label> <span class="ss-required-asterisk" aria-hidden="true">*</span></div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <select name="entry.895392494" id="entry_895392494" aria-label="Shop Responsible " aria-required="true" required=""><option value=""></option> <option value="Walls/Ceilings">Walls/Ceilings</option> <option value="Plumbing">Plumbing</option> <option value="Electrical">Electrical</option> <option value="HVAC/Sheet Metal">HVAC/Sheet Metal</option> <option value="Carpentry">Carpentry</option> <option value="Interiors">Interiors</option> <option value="Exteriors">Exteriors</option> <option value="Masonry">Masonry</option> <option value="Mechanics">Mechanics</option> <option value="Structural">Structural</option></select> <div class="required-message">This is a required question</div></div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-select"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_1493538421"><div class="ss-q-title">Issue Type </div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <select name="entry.1493538421" id="entry_1493538421" aria-label="Issue Type "><option value=""></option> <option value="Poor Workmanship">Poor Workmanship</option> <option value="Lack of Training">Lack of Training</option> <option value="Not Per Plans">Not Per Plans</option> <option value="Not Per Code">Not Per Code</option> <option value="Not Per Spec">Not Per Spec</option> <option value="Plan Conflict">Plan Conflict</option></select> <div class="required-message">This is a required question</div></div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-paragraph-text"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_177485091"><div class="ss-q-title">Notes/Actions </div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <textarea name="entry.177485091" rows="8" cols="0" class="ss-q-long" id="entry_177485091" dir="auto" aria-label="Notes/Actions "></textarea> <div class="error-message" id="754075454_errorMessage"></div> <div class="required-message">This is a required question</div> </div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-item-required ss-date"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_1875356531"><div class="ss-q-title">Follow-Up Date <label for="itemView.getDomIdToLabel()" aria-label="(Required field)"></label> <span class="ss-required-asterisk" aria-hidden="true">*</span></div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <input type="date" name="entry.1875356531" value="" class="ss-q-date" dir="auto" id="entry_1875356531" aria-label="Follow-Up Date " aria-required="true" required=""> <div class="required-message">This is a required question</div></div></div></div> <input type="hidden" name="draftResponse" value="[,,"3618330731406970920"] "> <input type="hidden" name="pageHistory" value="0"> <input type="hidden" name="fbzx" value="3618330731406970920"> <tr> <td>Image File</td> <td> <input type="file" name="uploadedFile" class="gwt-FileUpload"> </td> </ol></div> <div style="width: 100%; display: block; float: right;"> <button id="send" type="submit"> Send </button> </div> </form> </div> <script type="text/javascript"> function postToGoogle() { var field1 = $("input[type='radio'][name='qs1']:checked").val(); var field2 = $("input[type='radio'][name='qs2']:checked").val(); var field3 = $('#feed').val(); $.ajax({ url: "https://docs.google.com/forms/d/1jkIpSFH16SiNlsj13cBBRsuoiXmqeGVAI6PttCQiff8/formResponse", data: {"entry.1023121230": field3, "entry.1230072460": field1, "entry.2113237615": field2}, type: "POST", dataType: "xml", statusCode: { 0: function() { //Success message }, 200: function() { //Success Message } } }); } $(document).ready(function(){ $('#form').submit(function() { postToGoogle(); return false; }); }); </script> </body> </html> Reply With Quote 01-27-2015, 10:10 AM #2 Dormilich View Profile View Forum Posts Senior Coder Join Date Jan 2010 Location Behind the Wall Posts 3,532 Thanks 13 Thanked 372 Times in 368 Posts first you should verify whether your AJAX actually sends something off: open the browser’s dev tools and check the network panel for any outgoing requests. I might as well mention the SOP (same origin policy) here that governs which URLs you are allowed to contact. I would like to use this code for multiple object on a single page. Code: <SCRIPT LANGUAGE="JavaScript"> function ClipBoard() { holdtext.innerText = copytext.innerText; Copied = holdtext.createTextRange(); Copied.execCommand("Copy"); } </SCRIPT> <SPAN ID="copytext" STYLE="height:150;width:162;background-color:pink"> Text of stuff </SPAN> <TEXTAREA ID="holdtext" STYLE="display:none;"> </TEXTAREA> <BUTTON onClick="ClipBoard();">Copy to Clipboard</BUTTON> The problem is im not sure how to get more than 1 SPAN ID to work with the script. any help would be great! Could someone please change this line so that it respects the global namespace: Code: var selected = students.options[students.selectedIndex].value; The error console is telling me to use document.getElementById but I don't know where to put it. Thanks. I'm a total noob who decided to learn som web programming, I hope it's okey to post such questions here. I've written a script to learn how to fill in a value into a textarea by a button click. (See below.) I get it to show the selected number of each button, however the numbers just flashes and disappers right away. I want it to stay in the textarea. How do I do that and why does this problem appear? Head section <script type="text/javascript"> function calculon(i) { document.forms['siffror'].elements['test'].value = i; return; } body section <form name="knappar"> <input name="sifferknapp" type="submit" value=1 onClick=calculon(this.value)> <input name="sifferknapp" type="submit" value=2 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=3 onclick=calculon(this.value)><br /> <input name="sifferknapp" type="submit" value=4 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=5 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=6 onclick=calculon(this.value)><br /> <input name="sifferknapp" type="submit" value=7 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=8 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=9 onclick=calculon(this.value)><br /> </form> Every year or two, I want to do something SIMPLE via JS, and each time it's like i've never been there before I simply want a button to show/hide something on click, and I THINK I'm close, but it's not quite working. Here's what I'm toying with. Code: <html> <head> <script type="text/javascript"> function showHide("idName") { if(document.getElementById("idName").style.visibility=="hidden") { document.getElementById("idName").style.visibility=="visible"; } else { document.getElementById("idName").style.visibility=="hidden"; } } </script> </head> <body> <button type="button" onclick="showHide(1)">Click Me!</button> <div id="1" "style=visibility:hidden;"><p>this is the stuff.</p></div> </body> </html> How do I get the button to make that div (in)visible?? ~Mo Very new to javascript, so I apologize in advance. I honestly tried to figure this out on my own, and I'm just not able. I'm trying to create a family tree online that has several other related family charts. I want each person's name and birth year to be stored in javascript variables, then I want to be able to just go through the tree, and put the persons name once, and have it put the appropriate name and birthyear in the little boxes that the css is creating. In the js file... I would do this for each family member. Code: var johnname = "John Smith"; var johnbirthyear = "Jan 1 1930"; var janename = "Jane Doe"; var janebirthyear = "Jan 1 1940"; var mikename = "mike wilson"; var mikebirthyear = "Jan 1 1950"; var saraname = "sara johnston"; var sarabirthyear = "Jan 1 1960"; In the HTML file... Code: <div id = "boybox"> <script type="text/javascript"> id = "john"; <!-- this is the only thing I want to have to change --> name = id+"name"; document.write(name); </script> <div id = "year"> <script type="text/javascript"> birthyear = id+"year"; document.write(birthyear); </script> </div> </div> So I thought I had it all figured out. I thought that the above would take the id of John that I added, go to the line that sets the name, add john to the word name, and then document write the variable of johnname from the js file. I know you're laughing at me because of course it instead made the value of name to johnname, then wrote the word johnname in the box. Can anyone point me in the right direction please? ultimately I want to go through and be able to just type the persons name in the html for that box once, and have it update with their appropriate info. Thanks, and sorry for such a rookie question. I am very new to javascript and really can't figure out what I am doing wrong. I am trying to make a 1 page store that allows you to type in an item and select the color and size you want for that item. If you don't fill in a field, an alert message should tell you that. If all the fields are filled in, a "thank you for purchasing ____________" message should appear in a text area at the bottom of the page. This is my current code: Code: <html> <head> <script> function processform() { if ( document.form1.item1.value == "") { alert("No Item Chosen") } else { chosen = "" len = document.form1.c1.length for (i = 0; i <len; i++) { if (document.form1.c1[i].checked) { chosen = document.form1.c1[i].value } } if (chosen == "") { alert("No Color Chosen") } } else { itemname = document.form1.item1.value; itemcolor = document.form1.c1.value; itemsize = document.form1.size.value; document.form1.txtarea1.value = "Thank you for purchasing a " + itemsize + " " + itemcolor + " " + itemname; } } </script> </head> <body> <h1>Store</h1> <br/><br/> <form name="form1"> <h4>What item would you like to buy?</h4> <input type="text" name="item1" value="" /><br /> <br/><br/> <h4>Color</h4> <input type="radio" name="c1" value="blue" /> Blue<br /> <input type="radio" name="c1" value="red" /> Red<br /> <input type="radio" name="c1" value="green" /> Green<br /> <input type="radio" name="c1" value="yellow" /> Yellow<br /> <br/><br/> <h4>Size</h4> <select name="size"> <option value="small">Small</option> <option value="medium">Medium</option> <option value="large">Large</option> <option value="extra large">Extra Large</option> </select> <br/><br/> <button onclick="processform()">Purchase</button> <br/><br/> <textarea rows="2" cols="40" name = "txtarea1"> </textarea> </form> </body> </html> When I press the purchase button, no alert message is shown, nor does anything get displayed in the textarea. What am I doing wrong? Hi, I am looking for an efficient way to go thru all the list items I have in an unordered page and change an attribute. I know I should be able to do it using getElementsByTagName, but I can't seem to get it all working. Can someone please point me in the right direction? Thanks, Thad I used the Google Internal Site Search script for my site but its search only the index.htm, how can I make it search the entir web site.
I have been trying to find out how i can change this basic search script to be able to open on the same page, at the moment when you do a search it opens up on another page, i would like to be able to make this open on the same page, any help would be great! <script language="JavaScript" type="text/javascript"> <!-- function search_google(){ window.open("http://www.google.co.uk/#hl=en&source=hp&q="+document.search.query.value); } //--> </script> <form name="search" onsubmit = "search_google()"> <input type="text" name="query" value=""> <input type="submit" value="Search Google" > </form> How do Google and Bing allow you to use the keyboard up and down keys to jump to the suggested search results. I know how to do the Ajax search part, I just can't figure out how to get the search suggestions selected, and fire their HREF tag upon clicking the Enter button. Basically I can do all this without any keyboard navigation but I need to hook in the keyboard like they do. Is there a simple example somewhere? Google and Bing's are super complex and I can't snoop how they pull it off. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 I am learning to programme in HTML5 and Java, and I'd like some assistance with what I am sure is a pretty basic matter, if possible please? If anyone can assist it would be most appreciated? I am using Dreamweaver (latest version)... This code here below when run produces a google map with a street address look up input. I am wanting to learn how to look up an address and submit this to resolve within the map, and also to insert a place holder... I'd like the look up box to sit within (and overlay) the map top left area - at the moment it sits below the map - which i guess is because I haven't inserted a frame?? Many Thanks grin): ***CODE*** <!DOCTYPE html> <html> <head> <style type="text/css"> html, body, #map-canvas { height: 100%; margin: 5; padding: 5;} </style> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"> </script> <script type="text/javascript"> function initialize() { var mapOptions = { center: { lat: -34.397, lng: 150.644}, zoom: 8 }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> </body> <head> <title>Place Autocomplete Address Form</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <style> html, body, #map-canvas { height: 100%; margin: 0px; padding: 0px } </style> <link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"></script> <script> // This example displays an address form, using the autocomplete feature // of the Google Places API to help users fill in the information. var placeSearch, autocomplete; var componentForm = { street_number: 'short_name', route: 'long_name', locality: 'long_name', administrative_area_level_1: 'short_name', country: 'long_name', postal_code: 'short_name' }; function initialize() { // Create the autocomplete object, restricting the search // to geographical location types. autocomplete = new google.maps.places.Autocomplete( /** @type {HTMLInputElement} */(document.getElementById('autocomplete')), { types: ['geocode'] }); // When the user selects an address from the dropdown, // populate the address fields in the form. google.maps.event.addListener(autocomplete, 'place_changed', function() { fillInAddress(); }); } // [START region_fillform] function fillInAddress() { // Get the place details from the autocomplete object. var place = autocomplete.getPlace(); for (var component in componentForm) { document.getElementById(component).value = ''; document.getElementById(component).disabled = false; } // Get each component of the address from the place details // and fill the corresponding field on the form. for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; document.getElementById(addressType).value = val; } } } // [END region_fillform] // [START region_geolocation] // Bias the autocomplete object to the user's geographical location, // as supplied by the browser's 'navigator.geolocation' object. function geolocate() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var geolocation = new google.maps.LatLng( position.coords.latitude, position.coords.longitude); autocomplete.setBounds(new google.maps.LatLngBounds(geolocation, geolocation)); }); } } // [END region_geolocation] </script> <style> #locationField, #controls { position: relative; width: 480px; } #autocomplete { position: absolute; top: 0px; left: 0px; width: 99%; } .label { text-align: right; font-weight: bold; width: 100px; color: #303030; } #address { border: 1px solid #000090; background-color: #f0f0ff; width: 480px; padding-right: 2px; } #address td { font-size: 10pt; } .field { width: 99%; } .slimField { width: 80px; } .wideField { width: 200px; } #locationField { height: 20px; margin-bottom: 2px; } </style> </head> <body onload="initialize()"> <div id="locationField"> <input id="autocomplete" placeholder="Enter your address" onFocus="geolocate()" type="text"></input> </div> <table id="address"> <tr> <td class="label">Street address</td> <td class="slimField"><input class="field" id="street_number" disabled="true"></input></td> <td class="wideField" colspan="2"><input class="field" id="route" disabled="true"></input></td> </tr> <tr> <td class="label">City</td> <td class="wideField" colspan="3"><input class="field" id="locality" disabled="true"></input></td> </tr> <tr> <td class="label">State</td> <td class="slimField"><input class="field" id="administrative_area_level_1" disabled="true"></input></td> <td class="label">Zip code</td> <td class="wideField"><input class="field" id="postal_code" disabled="true"></input></td> </tr> <tr> <td class="label">Country</td> <td class="wideField" colspan="3"><input class="field" id="country" disabled="true"></input></td> </tr> </table> </body> </html> Hello, I'm using google voice search on a simple form: Code: <form action="http://www.google.com/search"> <input type="search" name="q" speech required onspeechchange="startSearch"> </form> How to activate the voice search, that is generally activated by clicking on the little microphone near the textbox, without clicking it? I want it to start recording the voice after the user starts talking, or alternatively, after a tot # of seconds.. I did not find anything on the API: http://www.w3.org/2005/Incubator/htm...api-draft.html I thank you in advance hi all i'm kind of new to the JS world and need your help with some thing i hope it not that big to ask. if you go to linkedin website with your user (www.linkedin.com) you will see a bar called LinkedIn Today. what i need is this kind of bar but with messages changing all the time(moving) is this some thing i need to write from scratch or there some example that i can use? any help will be good for me now because i need to do it ASAP regards,shay Hey guys I'm new to Javascript and need some help with this code Code: <HTML> <HEAD> <TITLE>Swap Test</TITLE> </HEAD> <BODY> <script type="text/javascript"> var numberOne; var numberTwo; // Declaring the values of numberOne and numberTwo var numberOne = 9; var numberTwo = 1; // Variables are swapped numberOne = numberTwo; numberTwo = numberOne; // Output is displayed on-screen document.write (numberOne); document.write (numberTwo); </script> </BODY> </HTML> What I need to do is to declare the two variables, swap their values and then show the results on the screen. ...but it's not working, any ideas? Thanks! x |