Jump to content

svdb

Members
  • Posts

    23
  • Joined

  • Last visited

svdb's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I'm working on this website that has a table for users in its database and another table for the so called products that users can post. Each user has location data in the user table (placenaam, latitude and longitude). When I display the products I want to show this user's location data with each product. So what's more efficiënt, to copy this data to the products table and store double data. Or is it more efficiënt to query the data from the users table for each product. $getproducts = mysql_query("SELECT * FROM products"); while($row = mysql_fetch_array($getproducts)) {//This will give me all the product information I need if I add the location data to the products table. Otherwise I should do something like this: $getlocation = mysql_query("SELECT lat, lng, place FROM users WHERE username = '".$row."'"; while($loc = mysql_fetch_array($getlocation)){echo "LOCATION DATA";[/indent][indent=1]}//end while }//end while Hopefully anyone has an advise what to do here.
  2. Thanks for your quick response. codeSearch(a, b ); worked perfectly for me.I knew it couldn't be hard
  3. Hi, I need to execute a function in order to set a circle on google maps api. But before that the old circle should be cleared.This works fine, but I want to send some values a and b with it to use in the second function codeSearch So I got this on my page: <input type="submit" onclick="clearCircle('abc','abc');" /> Then this function is executed: function clearCircle(a, { circle.setMap(null); codeSearch.call(a, ;} It now does start the codeSearch function, but a, and b are undefined. Is there a way to do this rightly.Thanks
  4. Hi, I have this script for registration form validation. It has three functions: - to check if the emailadress is valid, this function is initiated onblur- to check password lenght and whether or not the password control field matches the first input- to double check for the things above plus to check if there are any empty mandatory fields when the submit button is clicked. The first two work fine, the third works for all fields except the password lenght and match control. I don't understand why because I exactly used the same code in the first two functions and they work fine. Here is the code, hope someone can tell me what's going wrong. function checkPass(){ var pass1 = document.getElementById('password'); var pass2 = document.getElementById('passwordcontrol'); var message = document.getElementById('confirmMessage'); var goodColor = "#AFC100"; var badColor = "#f20000"; if (pass1.value.length < 4){ pass2.style.borderColor = badColor; message.style.color = badColor; message.innerHTML = "Wachtwoord is te kort"; } else if(pass1.value == pass2.value){ pass2.style.borderColor = goodColor; message.style.color = goodColor; message.innerHTML = "Wachtwoord is correct"; } else{ pass2.style.borderColor = badColor; message.style.color = badColor; message.innerHTML = "Wachtwoord komt niet overeen"; } } function validateEmail() { var mail = document.getElementById('mail'); var message = document.getElementById('mailMessage'); var badColor = "#f20000"; var goodColor = "#AFC100"; var x=document.forms["registerform"]["mail"].value; var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { mail.style.borderColor = badColor; message.style.color = badColor; message.innerHTML = "Ongeldig e-mailadres"; } else { mail.style.borderColor = goodColor; message.innerHTML = "" } } function validateForm() { var valid = true; var badColor = "#f20000"; var u=document.forms["registerform"]["username"].value; var p=document.forms["registerform"]["password"].value; var pc=document.forms["registerform"]["passwordcontrol"].value; var m=document.forms["registerform"]["mail"].value; var pstc=document.forms["registerform"]["postcode"].value; var pts=document.forms["registerform"]["plaats"].value; var s=document.forms["registerform"]["straat"].value; var nr=document.forms["registerform"]["nummer"].value; var atpos=document.getElementById('mail').value.indexOf("@"); var dotpos=document.getElementById('mail').value.lastIndexOf("."); var pass1 = document.getElementById('password'); var pass2 = document.getElementById('passwordcontrol'); var message = document.getElementById('confirmMessage'); var message = document.getElementById('warnMessage'); if (u==null || u=="") { document.getElementById('username').style.borderColor = badColor; valid = false; } if (p==null || p=="") { document.getElementById('password').style.borderColor = badColor; valid = false; } if (pc==null || pc=="") { document.getElementById('passwordcontrol').style.borderColor = badColor; valid = false; } if (m==null || m=="") { document.getElementById('mail').style.borderColor = badColor; valid = false; } if (pstc==null || pstc=="") { document.getElementById('postcode').style.borderColor = badColor; valid = false; } if (pts==null || pts=="") { document.getElementById('plaats').style.borderColor = badColor; valid = false; } if (s==null || s=="") { document.getElementById('straat').style.borderColor = badColor; valid = false; } if (nr==null || nr=="") { document.getElementById('nummer').style.borderColor = badColor; valid = false; } if (!document.registerform.akkoord.checked) { document.getElementById('voorwaarden').style.border = "medium solid #f20000"; valid = false; }// the two if's below don't work if (pass1.value.length < 4 ) { valid = false; } if (pass1.value != pass2.value) { valid = false; }// if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { valid = false; } if (!valid) { window.scrollTo(0,0); message.style.color = badColor; message.innerHTML = "U heeft niet alle verplichte velden juist ingevuld."; return false; } else { return true; } } Any other tips on the script are welcome, i'm new to javascript.
  5. But, when this is true, why does my text editor give the same error?
  6. Oké, I did as you said in Firefox. It says: missing ; before statement Line: 5, Column: 8 That would be this line: <script type="text/javascript"> Seems error free to me...
  7. I made some screenshots
  8. I'm not very familiar with JavaScript. I'm implementing a Google Maps API into my website and using the exact code google provides in the developers guide. But it gives an error, this is the code <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=mykey_ididchangethis&sensor=false"></script><script type="text/javascript"> function initialize() { var frontmap = { zoom: 8, center: new google.maps.LatLng(52.22, 4.53), mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById('map_canvas'), frontmap); } function loadScript() { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://maps.googleapis.com/maps/api/js?sensor=false&' + 'callback=initialize'; document.body.appendChild(script); } window.onload = loadScript;</script> It says: missing ; before statement (on column 2) So any ideas? Thanks
×
×
  • Create New...