Jump to content

Uzm

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Uzm's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. All right, i'll try to explain a bit more. It's not really unique, but i haven't seen any questions related to similar problem yet, so that's why i think it's unique. Array: $div = array("Title" => "1", "Link" => "http://blablabla.com", "Image" = "image.jpg"); $divText = array("1" => "text 1", "2" => "text 2); Then, the HTML: <div> <span class="title"><!-- title from $div goes here --></span><br> <a href="<!-- link from $div goes here -->" target="_blank">link</a> <img src="<!-- image from $div goes here -->" alt="Death Race"><br><br> <span class="text"><!-- text from $divText goes here --></span> </div> It seems pretty simple, but i can't get it to loop. Let's say that i have 20 arrays, that need to display $div and $divText parameters.
  2. I'm creating a small project, but i can't figure out how to use array looping properly. I'm making multiple DIVs that will show title, link, and an image. Let's say there are 20 DIVs. In each DIV, below the image, there's text. Each DIV has different text. I've tried in different ways, but i can't get anywhere. Google didn't help much, since it's quite "unique" system of looping. Is there any solution for such task?
  3. Maybe this will help you? var url = "checknick.php?name="; function checkName() { document.getElementById('ajax_answer').innerHTML = "...loading, please wait..."; var name = document.getElementById("nickname").value; http.open("GET", url + escape(name), true); http.onreadystatechange = handleHttpResponse; http.send(null); } function handleHttpResponse() { if (http.readyState == 4) { results = http.responseText; var name = document.getElementById("nickname").value; document.getElementById('ajax_answer').innerHTML = results; } } function createRequest() { try { return new XMLHttpRequest(); } catch (trymicrosoft) { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { alert("Error initializing XMLHttpRequest!"); } } } } var http = createRequest(); HTML: Nickname: <input name="name" id="nickname" type="text" onblur="checkName();" /> <span id="ajax_answer"><br><br> Explanation: When you're finished entering user's nickname in the field, it'll call the script /checknick.php?name=(users nickname), and fetch the data from it, then display in SPAN "ajax_answer". All you need to do now is to create database-checking checknick.php. Hope this helps!
  4. Hello guys. I've been working on an AJAX/PHP/MySQL-chat for a bit now, and recently run into a problem that i can't really solve, and getting a bit desperate. The problem is that i'm getting loads of "undefined" errors, and sometimes requests (aspecially on function getData()) ain't getting response. I've been googling about this a lot, read loads of topics on loads of forums, and more, but i can't solve my problem. Could you help me a bit? var chatUrl = "http://localhost/chat/"; var imgloaded = new Array(); var msgtime = 1; var imgdir = "http://localhost/chat/images/"; var sysimages = new Array("info.gif", "pr.gif", "privat.gif"); var sysloaded = new Array(); var loggedIn = false; var userId; var userName; var level; var yo; var exitRequest = createRequest(); var sendMsgRequest = createRequest(); var getDataRequest = createRequest(); var enterChatRequest = createRequest(); var loadedTimeout = 3500; var loadingTimeout = 3500; var date = new Date(); var timestamp = date.getTime(); var images = new Array(["01.gif", ":цоол"],["02.gif", ":слёзы"],["03.gif", ":дурак"],["04.gif", ":цветы"],["05.gif", ":хурхур"], ["06.gif", ":неа"],["07.gif", ":о"],["08.gif", ":ржу"],["09.gif", ":глазки"],["10.gif", ":роза"],["11.gif", ""],["12.gif", ":сплю"],["13.gif", ""],["14.gif", ":вылез"],["15.gif", ":растяг"],["16.gif", ":ога"],["17.gif", ""],["18.gif", ":обида"],["19.gif", ":двигай"],["20.gif", ":правила"],["21.gif", ":гнев"],["22.gif", ":гы"],["23.gif", ":ура"],["24.gif", ":хмм"],["25.gif", ":ангел"],["26.gif", ":стоп"],["27.gif", ":подлиз"],["28.gif", ":смех"],["29.gif", ":любовь"],["30.gif", ":пока"],["31.gif", ":прости"],["32.gif", ":ляля"],["33.gif", ":смущение"],["34.gif", ":язык"],["35.gif", ":поцелуй"],["36.gif", ":целуются"],["37.gif", ":айкидо"],["38.gif", ":отдых"],["39.gif", ":босс"],["40.gif", ":команда"],["41.gif", ":псих"],["42.gif", ":ковыряю"],["43.gif", ":ах"],["44.gif", ":кик"],["45.gif", ":автомат"],["46.png", ")"],["47.gif", ":палец"],["48.png", ":нини"],["49.png", ":аццтой"],["50.png", ":зелёный"],["51.png", ":молчу"],["52.png", ":молодец"],["53.png", ":гасп"],["54.png", ":херасе"],["55.png", ":зубы"],["56.png", ":брр"],["57.gif", ":слушаю"],["58.gif", ":помидоры"],["59.gif", ":крошим"],["60.gif", ":стена"],["61.gif", ":мат"],["62.gif", ":курю"],["63.gif", ":кенни"],["64.gif", ":программер"],["65.png", ":слюни"],["66.gif", ":соска"],["67.gif", ":пиво"]); for (i = 0; i < sysimages.length; i++) { sysloaded[i] = new Image(); sysloaded[i].src = imgdir + sysimages[i]; } function createRequest() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Error initializing XMLHttpRequest!"); } } function loaded () { document.getElementById("win").style.visibility = "visible"; document.getElementById("main").style.visibility = "hidden"; yo = setTimeout('getData()', loadedTimeout); } function exit () { exitRequest.open("POST", chatUrl + "exit.php", true); exitRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); exitRequest.send(""); clearTimeout(yo); loggedIn = false; document.getElementById("main").style.visibility = "visible"; document.getElementById("win").style.visibility = "hidden"; } function send (msg, to) { if (sendMsgRequest.readyState == 4 || sendMsgRequest.readyState == 0) { sendMsgRequest.open("POST", chatUrl + "send.php", true); sendMsgRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); sendMsgRequest.send("msg=" + encodeURIComponent(msg) + "&userId=" + userId + "&to=" + to + "&timestamp=" + timestamp); } } function getData() { if (getDataRequest.readyState == 4 || getDataRequest.readyState == 0) { getDataRequest.open("POST", chatUrl + "get.php", true); getDataRequest.onreadystatechange = getDataEvent; getDataRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); getDataRequest.send("userId=" + userId + "&msgtime=" + msgtime + "&timestamp=" + timestamp); } if (loggedIn == true) { yo = setTimeout('getData()', loadingTimeout); } } function getDataEvent() { if (getDataRequest.readyState == 4) { if (getDataRequest.status == 200) { if (getDataRequest.responseText.substr(0,1) == "|") { clearTimeout(yo); alert(getDataRequest.responseText.substr(1,getDataRequest.responseText.length - 1)); exit(); } else { var lines = getDataRequest.responseText.split('\n'); lines.length = lines.length - 1; if (lines.length > 0) { onlineUserList = lines[0].split("|"); onlineUserList.length = onlineUserList.length - 1; } if (lines.length > 1) { for (i = 1; i < lines.length; i++) { var msg = lines[i].split("|"); try { parent.talk.printmsg(msg[0],msg[1],msg[2],msg[3]); } catch (e) { } msgtime = msg[4]; } } seichas = document.getElementById("chatlan"); mysp = document.createElement("span"); hrprfr = document.createTextNode("ЮЗЕРОВ ОНЛАЙН: " + onlineUserList.length); mysp.appendChild(hrprfr); seichas.replaceChild(hrprfr, seichas.firstChild); parent.menu.printmenu(); } } else { alert("Ошибка запроса к серверу: " + enterRequest.status); } } } function enterChat (userName, password) { if (enterChatRequest.readyState == 4 || enterChatRequest.readyState == 0) { enterChatRequest.open("POST", chatUrl + "enter.php", true); enterChatRequest.onreadystatechange = enterChatEvent; enterChatRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); enterChatRequest.send("login=" + userName + "&password=" + password); } } function enterChatEvent() { if (enterChatRequest.readyState == 4) { if (enterChatRequest.status == 200) { if (enterChatRequest.responseText.indexOf("|") != -1) { var user = enterChatRequest.responseText.split("|"); userId = user[0]; userName = user[1]; level = user[2]; loggedIn = true; loaded(); } else if (enterChatRequest.responseText == 'n') { alert("Ошибка при входе в чат: Вы ввели неправильный логин и/или пароль!"); } else { alert("Ошибка при входе в чат: " + enterChatRequest.responseText); } } else { alert("Ошибка запроса к серверу: " + enterChatRequest.status); } } }
  5. @twostars: Question was to convert for instance "2007-01-13" to "13th January 2007".
  6. I was wondering if there is any way of displaying a readable date in swedish? For example, i have a date: "2007-01-13". That would be Sunday, 13th January 2007, and Söndag, 13 Januari 2007 on swedish. Could anyone describe to me how i can convert dates in this format?
  7. Erm, you can do like this: <?php echo "<input type=\"button\" onClick=\"parent.location='URL'\" value=\"GO TO URL\">"; ?>
  8. Thank you chronister, that's exactly what i was looking for.
  9. All right. Let say, that we have 3 SELECT-menus. First is named "1", second "2", and third "3". User has to choose values from ALL select-menus. But instead of choosing ALL of them, user only chooses SELECT-menu "1", and doesn't choose anything from second and third menu. I want to deny those kinds of submits. If user chooses something from first menu, then he/she HAS to choose a value from second and third menu aswell.
  10. pocobueno1388: Thanks for a nice solution, but that wasn't really what i was searching for. I'll try to explain a little closer. Loads of users that registrate themselves on that page, only choose their birthdate month and day, but not YEAR. So, what i want to do is to check, IF year, month OR day has been choosed - but not not the complete birthdate-forms (year/month/day) - for instance if user chooses only his year of birthdate, but doesn't choose day or month of birthdate - user will receive an error. Also, i want to give a apportunity to users not to select their birthdate. So that's really the problem itself.
  11. Hey! Yesterday i've met a little problem with form validation for birthdate entries that my users enter on my registration page, so i'm asking for a little assistance from you guys. I have three forms on my registration page: select-menu named "birth_date_year", select-menu "birth_date_month" and "birth_date_day". What i want to decline submissions that HAVE selected a value from "birth_date_year", but NOT "birth_date_month" and/or "birth_date_day", or in other way. I've tried with operators, but it seems not to work. Anyone could help me with this? Thanks!
  12. Anyways, i havent found a solution for this problem YET. And URL specified in previous posts didn't help me that much (i'm talking about http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_soundex).
  13. Hey, all! Ok, i've been researching about this problem (if we can call it a problem) for a week now, and i simply can't find a good solution for it. So, i was wondering if you can help me with this one. I would appreciate this a lot. What i need to do is a PHP code, that will tell me difference between two dates in days/minutes/seconds. Let's say, that i've a date in format YYYY-MM-DD HH:MM:SS, and the current date. Yeah, this seems very simple, but i haven't found the right code for it. Thanks again.
  14. pocobueno1388, What i want to do is to block users to register similar names. Let's say, i have username "test" in my database. Then, if a user wants to register "test1" - MySQL cheks if there is a similar username (in this case: similar to "test"). IF there is a similar username to "test1" - the script will show an error.
×
×
  • 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.