Jump to content

WebStyles

Members
  • Posts

    1,216
  • Joined

  • Last visited

About WebStyles

  • Birthday 07/08/1974

Contact Methods

  • Website URL
    http://www.clickworks.org

Profile Information

  • Gender
    Male
  • Location
    Europe
  • Interests
    Php, MySql, Javascript, JQuery, CSS, Html, Python, Perl, Photography, Mechanics, Electronics, Painting, Drawing, Guitar...

WebStyles's Achievements

Newbie

Newbie (1/5)

6

Reputation

  1. here's a very simple example of a dropdown that calls a javascript function (submitChange) every time something is selected. You would use that function to grab the dropdown value and create an ajax call to a php file. <!-- html form dropdown example --> <select name="year" onchange="submitChange()"> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> </select> <?php // page that ajax calls $year = trim($_POST['year']); $query = "select `something` from `something`"; if(!empty($year)){ $query .= " where `year` = '$year'"; } ?> Hope this helps
  2. There are many geolocation webservices available that will return country/city based on ip address. Try googling them. Most of them will have some sort of limit (like 1000 requests per month or whatever), but you can buy more for small fees. here's one example: https://freegeoip.net Hope this helps
  3. A few things to consider: - What's the point of hashing the password if you're going to store the plaintext one too? - You should not use md5 for password hashing. - You should sanitize the fields properly before inserting into database - empty() will also check if variable exists, so using isset() on all variables and then empty() is redundant - Your sql statement should say VALUES and not VALUE
  4. here's an example of an Ajax request and POST to a php page. function createRequest(){ var xmlhttp = false; if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ } } } if(!xmlhttp) { return false; }else{ return xmlhttp; } } function callFile(uid){ var url = '_php/myscript.php'; var msg = "&uid="+uid; var xmlhttp = createRequest(); if(!xmlhttp) { return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4){ // DO SOMETHING HERE alert(xmlhttp.responseText); } } // POST STUFF xmlhttp.open("POST", url, true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", msg.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(msg); } Hope this helps
  5. this is the same as your previous post called 'undefined Var Errors' and it seems you didn't even bother to try the things we suggested at the time. for example, you're still doing this: $sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { after I have explained to you that looping through results when you know there's only going to be one (LIMIT 1) is silly.
  6. Love this comment. "ie not a problem" lol (just had to say that). Now, regarding your problem, please post the actual code of the page where this is happening.
  7. Try confirm('...') instead of alert('...') $result[code] //should be $result['code']
  8. wow man, that's some crazy code... where is $saltpass defined?
  9. Before we read through all that code, care to explain what error you're getting (or what you expect should happen that is not happening)? P.S. session_start() sould be at the top of the file.
  10. here's a simple working example of how one box can change the other. You should be able to adapt it to your case: <html> <head><script> function updateValues(a){ // get the value that's selected var b = a.options[a.selectedIndex].value; // set the value on next box var doctor = document.getElementById('doctor'); var cnt = doctor.length; for (var i=0; i < cnt; i++){ if (doctor.options[i].value == b){ doctor.options[i].selected = true; } } } </script> </head> <body> <select id="field" name="field" onchange="updateValues(this)"> <option value="0">please select one</option> <option value="1">One</option> <option value="2">Two</option> </select> <br><br><br> <select id="doctor"> <option value="0">nothing selected</option> <option value="1">Doctor One Selected</option> <option value="2">Doctor Two Selected</option> </select> </body> </html> Hope that helps
  11. Ok, the select box that you can change (field), you need to add an onChange="" tag that will call your javascript function every time you change the value. so, something like this: (imagine the javascript function is called updateValues <select name="field" onchange="updateValues()"> this is a basic example, your javascript function would be something like this: (assuming the value of one is the index of the other) function updateValues(){ // get the value that's selected var a = document.getElementById("field"); var b = a.options[a.selectedIndex].value; // make other box change document.getElementById("doctor").selectedIndex = b; }
  12. there's no javascript in your code. Try google something like "javascript get <select> value" EDIT: opsss... Sorry, just saw the javascript code mixed in at the end. Hang on, I'll have a look for you.
  13. check if you're by any chance including 2 functions with the same name.
  14. here's proof that it does work: <html> <head><script> function checker(file,type) { alert(file+' '+type); }</script> </head> <body> <?php echo '<a href=\'javascript:checker("checker_r.php","a")\'>test</a>'; ?> </body> </html> replace your javascript function with a single echo like I did. If you get a popup, then the error is somewhere in the javascript function and not the button call.
  15. then you didn't post the original code properly. The way you posted it made it seem like is was html, when in fact you are echo(ing) it from php. Try escaping the outer quotes: echo '<a href=\'javascript:checker("checker_r.php","a")\'><img src="images/accept.png" alt="Accept" /></a>';
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.