Jump to content
Larry Ullman's Book Forums

sonal

Members
  • Posts

    121
  • Joined

  • Last visited

  • Days Won

    2

sonal last won the day on June 19 2012

sonal had the most liked content!

sonal's Achievements

Newbie

Newbie (1/14)

8

Reputation

  1. As I'm exploring web development, I found wordpress interesting, popular and "need to know" kind of thing. So, far I come to know about different themes and how to set up it among other basic stuff. I like to know : 1. How to I know where I need to change PHP code? I mean which file for what purpose? I know there is lot of WordPress tutorials and resources around there, but it is overwhelming and making me more confused. 2. I see posts filed under series on this site. Like there are Yii series, jQuery series and more. How do I collect posts filed under different categories and then show them as series? Sonal
  2. I want to add a modal window (created with css and javascript) to pop-up a form when a user clicks "add quote" button on one of my php script. I have created a form in q1.html file, with required div settings. There is a modal.css file as Larry has given in the book. This html file on its own shows a poping up modal window with it's own "show window" button. Now, I want to include this html file in one of the php script. If I use a link with <a href" tag pointing to q1.html file, it opens up in an entire new window. That is of no use to use a poping up modal form. If I use "include('q1.html') file in php, the form stops working. The modal.css applies to the main page where I'm including this file. SO, how do I do it? I think the problem comes from DOM, as modal.js file asks for elements in html file. But I don't understand how to resolve it. I was searching on Internet, and all of it returns jquery solutions. At this point I don't want to use jqueary, as I want to learn javascript first. thanks
  3. Hi HartleySan, thanks for your suggestion. I did what you said (combine all different stuff into one file, making a new function for each task). AND MAGIC.. it's working, as I expected it to work. Good.. I like all these stuff about js, ajax and php really much.. But I would like to know, what of my code seems a bit odd? Will you please share your looks/concerns or anything that I'm doing wrong in above code? Thanks again..
  4. It is necessary to run your ajax script through a server. Larry has explained it like this, "If your request is returning a 0 status code, you probably are not making the request through a URL. I hope that's what where the problem is coming from in your case...
  5. I thought so. I should explain in detail what I'm upto. I want to display "quotable quotes" on index page. To do that I'm fetching quotes through ajax and putting that js script into my "header" html page. code for that: /* * return json data from quotelist.php using ajax. * */ window.onload = function() { 'use strict'; var quoteDisp = document.getElementById('qquote'); var jAjax = getXMLHttpRequestObject(); //This is defined in another file. Which is working nicely. jAjax.onreadystatechange = function() { if(jAjax.readyState == 4) { if((jAjax.status >= 200 && jAjax.status < 300) || (jAjax.status == 304)) { var output = jAjax.responseText; //alert(output); document.getElementById("qquote").innerHTML = output; } else { //alert("Error" + jAjax.statusText); } } }; //End of onreadystatechange anonumous function. jAjax.open('GET', 'quotelist.php', true); jAjax.send(null); }; //first form to display book names by title. It shows autolist as user keys in title, and then displays a book details selected from the list. Following two files are included on index page through a "main.php" script, which shows different pages collected by index page. I hope this makes sense. This scripts are online at www.myreadinglog.net. Although the front page shows only quotes displayed on left side bar under "quotable quotes". Two other forms can be seen by a logged in user only. both of php scripts return XML data. //functio to handle ajax response: function handleAjaxResponse(e) { 'use strict'; if(typeof e == 'undefined') e = window.event; var ajax = e.target || e.srcElement; if(ajax.readyState == 4 ) { if ((ajax.status >=200 && ajax.status < 300) || ajax.status == 304) { if(ajax.responseXML) { //display result. } } function sendValue() { var searchTerm = document.getElementById('searchTerm'); searchTerm = searchTerm.value; if(searchTerm.length > 3) { var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange = handleAjaxResponse; //ajax.open('GET', 'isbn31.php?searchterm=' + encodeURIComponent(searchTerm.value), true); ajax.open('GET', 'isbn31.php?searchterm=' + encodeURIComponent(searchTerm), true); ajax.send(null); // return false; } } window.onload = function() { 'use strict'; U.addEvent(document.getElementById('searchTerm'), 'keyup', sendValue); //addEvent function is in a separate file under U object, works fine. } Third script for second form file. It displays book details fetched through ISBN. Only one result is returned and displayed using ajax. function getData(e) { 'use strict'; if(typeof e == 'undefined') e = window.event; var Iajax = e.target || e.srcElement; Iajax.onreadystatechange = function() { if(Iajax.readyState==4) { if((Iajax.status >= 200&& Iajax.status<300) || (Iajax.status==304)) { if(Iajax.responseXML) { //display result } } } function sendVal() { var IsearchTerm = document.getElementById('searchterm'); IsearchTerm = IsearchTerm.value; var Iajax = getXMLHttpRequestObject(); Iajax.onreadystatechange = getData; Iajax.open('GET', 'newisbn.php?searchterm=' + encodeURIComponent(IsearchTerm), true); Iajax.send(null); // return false; } window.onload = function() { U.addEvent(document.getElementById('searchterm'), 'blur', sendVal); U.addEvent(document.getElementById('isbn'), 'blur', sendVal); U.addEvent(document.getElementById("isbn"), 'submit', sendVal); }
  6. Thanks a lot, HartleySan for your reply. Although, I have used different ajax objects in both forms they don't seem to work together. Still the problem is as it is. Each html file works great individually, but when I keep both of them on the same page, only one of it works. I also have included third js-ajax-php script on the same page. So, now this one works and the other two stopped working. How do I do that?
  7. I have two forms on my index page. Both of these forms uses ajax to fetch and display data on the page from different php scripts. Both works great individually, showing results as expected. But, when I put both of them at the same time one of them is not showing resulting data. I have used addEventListener in my javascript to add events and my ajax part of both scripts use ajax.send(null) at the end of a function sending data off to php. What can be the problem? What am I missing? thanx in advance
  8. I see examples how to fetch data from php to ajax (and display it via javascript.) As in log-in example, we can check whether there is a valid email and password entered, we can simply display "You are now logged in." Till here I understand and work out. But, now as the user logs in, I need to set the php session. The login form sends data to the ajax.php, which simply returns a success message. In other case, if I just use php to check valid login details, I can set php session as soon as the script finds match data. I know I can send ajax data through URL to second php page, where it can access through $_GET. But I want to get that data into SESSION rather than sending through URL. How I do that?
  9. First I would like to know how to plan in terms of developing the code. (Ok, so now I know there are 2 different things when it comes to plan.) Thanks
  10. May be this is an old question. May be I read something about website development planning in one of the Larry's newsletter. But, I don't remember it now. I really want to know in detail, up to the advanced level, how to plan a website? As well as, about the blog. Is this site, Larryullman.com, a website or a blog? I know the subject for my blog. So that brainstorming is kind of done. What things should I know if I plan a long-term, successful blog where I myself can keep interest of posting new entries? Now, I that I'm learning about website development technology since a year, I can write many different kind of things. So I keep doing little animations, form validations, AJAX techniques in Javascript, various php-database interactions and so on. But, I still need to know what do I do to make a good blend of all these html, css, javascript, php-database things? Hope to hear from you all. Thanks
  11. As far as I understand this case is something like : parseInt function is used to show how to convert randomly generated float numbers to integers, as random.js shows use of for loop. volume calculator uses if(isNan(volume)) condition to check whether the incoming value is valid number, to show if-else if conditionals. If a value is coming from text input, it may be treated as a number or a string. There is no guarantee that if you enter a number in a text type input it will treated as a number all the time. It is better to use parseInt or parseFloat function while making numeric calculations. I had this problem in one of my form, that numbers were not compared correctly before I used parse functions. May be this is different if we use number type text input for HTML5 form elements.
  12. I got it corrected. a, b and c values were coming from text type form fields. So they were comparing as strings rather than numbers. I had to use parseInt function to convert them to numbers before comparing them. That is a simple example to show how to use nested if. Thanks for looking....
  13. What is wrong with following neseted if conditions? This program shows wrong result to compare 3 integer numbers and find out maximum number. I'm so confused. This program gives a wrong maximum number. var a = prompt("Enter first number"); var b = prompt("Enter second number"); var c = prompt("Enter third number"); var answer; document.getElementById("no1").innerHTML = "a : " + a; document.getElementById("no2").innerHTML = "b : " + b; document.getElementById("no3").innerHTML = "c : " + c; if(a > { if (a > c) { //alert("a is maximu : " + a); answer = a +" a is maximum"; } else { //alert("c1 is max : " + c); answer = c + " c1 is maximum"; } } else { if(b > c) { answer = b +" b is maximum"; } else { //alert("c2 is maximum : " + c); answer = c + " c2 is maximum"; } } document.getElementById("show").innerHTML = answer;
  14. I was also looking at this question. May be there is an answer at this page : http://codex.wordpress.org/Post_Types I haven't been able to try it myself yet.
  15. oh, ok. here 'Quote' is a simple string (quotable quotes like thing). (I have kept its length from 20 characters to 800 alphabetic characters.)
×
×
  • Create New...