Jump to content

jeffman

Members
  • Posts

    7,761
  • Joined

  • Last visited

Everything posted by jeffman

  1. mailto: opens the default mail client. Even then, you can't rely on every browser/client to exchange the same information. I never use it. The solution you're probably thinking of does require a server script. I'm pretty sure you can search for one that requires minimal setup.
  2. The gap sounds like something CSS can fix.
  3. To address your other question more directly: AJAX is built into all modern browsers. You do not need to link to any special libraries or install any special files to use it. You can. (jQuery is a common example.) But you don't have to. Start here. Also, you might be surprised how often AJAX is being used to update pages that you visit frequently. Certainly it can do what you want. I am a college professor, and years ago I wrote a web-app that handles my students' grades. It is essentially an online spreadsheet. If I gave access to another user, I would create the kind of situation you are describing. EDIT. Actually, my students do have read-only access. Not a big deal.
  4. FWIW, it's not just Outlook. It's every mailer I ever tried.
  5. And this part can be handled in a single for-loop, without the cell array var cell = [row[0].insertCell(0),row[0].insertCell(1),row[0].insertCell(2),row[0].insertCell(3)];for (var j=0 ; j<4 ; j++){ child1 = cellGuts(i); cell[j].appendChild(child1); i++;}for (var j=0 ; j<4 ; j++){ cell[j] = row[1].insertCell(j);}for (var j=0 ; j<4 ; j++){ child1 = cellGuts(i); cell[j].appendChild(child1); i++;}
  6. Now all of this: var newAttrib = document.createAttribute("border");newAttrib.value = "1";newTable.setAttributeNode(newAttrib); //append border="1" to the table works just fine as this: newTable.border = "1"; Though I'd recommend doing that in CSS. Same with the image width property.
  7. This is the function I had in mind: function cellGuts(i){ var newAnchor = document.createElement("a"); var newImg = document.createElement("img"); newAnchor.href = "photos_t/" + filenames[i]; newImg.alt = filenames[i]; newImg.src = newAnchor.href; newImg.width = "200"; newAnchor.appendChild(newImg); return newAnchor;} Notice the values I'm passing to createElement() . I haven't looked at the rest of the code.
  8. Could you post the filenames array so I can run this? Also, I think you went overboard with all those attribute nodes. Have you tried simple dot notation?
  9. Did you try the solution in Post #5? It will work on any value, including From:
  10. Sure. Just use createElement to make the <a> and <img> elements. Then set their attributes. The only thing that varies is the value of i, so build a little function that accepts i as an argument and returns the populated <a> as an element object.
  11. What you have here ^^ is more correct. My only concern is that it repeats a lot of the same code. Some of the steps could be modularized, especially the construction of the innerHTML strings.
  12. What birbal said. Support is the bigger question here. The online PHP Manual is 1000 times more user friendly than Microsoft documentation. The online community of PHP developers is very friendly (like us). And since PHP syntax is almost the same as JavaScript syntax, that's also an argument for PHP.
  13. OK, additional research turns up a much easier solution: $s = '=?UTF-8?B?' . base64_encode($subject) . '?=';mail($to, $s, "My message");
  14. The appearance of headers is NOT determined by the Content-Type of the message. The header must contain its own type instructions. EDIT SEE NEXT POST What you want is some sort of iconv function. I've experimented with this, and here is the closest I can come to the exact solution $preferences = array( "input-charset" => "UTF-8", "output-charset" => "ISO-8859-1");$preferences["scheme"] = "Q";$h = iconv_mime_encode("", $subject, $preferences); This outputs something like this, which is fine : =?ISO-8859-1?Q?H=E9llo?= but the first two characters (": ") need to be stripped. If there is a truly perfect solution, someone else might know it. In theory, you should be able to do this: $h = iconv_mime_encode("Subject", $subject, $preferences); and that would give you a perfectly formed mail header. And this will work for most headers, such as BCC. But it doesn't work with the Subject header, because the mail() function creates its own Subject header. All you are permitted to send is the value of the subject header, and iconv_mime_encode() returns a name-value pair formatted as a complete header string. All this should be true for the TO header also.
  15. In the old days, when computers and browsers were slower, the accepted wisdom was to create the entire object, with all its children, before adding it to the DOM. This eliminated flicker as the bits and pieces popped into existence. Latency of this kind is no longer a problem (unless your table has thousands of elements, I guess) but I still do stuff like that old-school. La-la land has never been anything to worry about. It can even be a handy resource at times.
  16. Mixing the != with the || operator like that means the condition will always return true. Try changing the || operators to && .
  17. jeffman

    HTML Form

    A textarea is not like an input. It needs a closing tag. Any text the browser sees after the opening tag will be understood as the textarea's value.
  18. Try adding another class that has a ruleset overriding the primary class: <div class="modal-header other-class">
  19. You can learn a lot from CSSPlay.
  20. I'm glad it helped. I did know you were doing JavaScript because you were using an AJAX object. The AJAX object has a place to specify GET or POST. It might still be worth looking at. If you borrowed the loadXMLDoc function here, notice that it's preprogrammed with GET. It doesn't have to be; and if I understand your situation, it probably should not be. Any server request that changes data on the server should be a POST request.
  21. It sounds like the original doc is being cached. If you are using the GET request change it to POST. On the server side, you might send out these headers before sending your data: "Cache-Control: no-cache, must-revalidate""Pragma: no-cache"
  22. Have you tried var_dump($_POST) to see if your script even receives the button data? Have you checked for mysqli errors following the query?
  23. You are adding/changing the src attribute of a <td> element. I can watch it happen using my Inspect Element tool. Change your selector.
  24. This was a fun project. It's seems a little complicated until you realize you can use a lot of off-the-shelf parts. Normally, I'd teach you how to do it, but you really need some experience to fit all this together. 1. Cookies are the way to go, because you need long-term persistence. On the assumption you don't do PHP, I've accessed the cookies using JavaScript. I borrowed well-known cookie functions available at W3Schools. 2. I thought of saving the data as a bit-mask, but I haven't messed with that in years and didn't feel like learning it all over again now. So I chose JSON format. For older browsers, I borrowed a JSON substitute available at Mozilla. 3. I decided to randomize the whole array first (I borrowed this implementation of a well known technique from Stack Overflow) and store the array as a cookie in JSON format. During most page visits, the script will not randomize the array. Instead, it will open the cookie, turn the cookie into an array, pop off the last image in the array, and then store the shortened array as a cookie again. So with every visit, the user gets the next randomized image, until there are no more images in the array. At that point, the script randomizes the array again and stores it for a fresh cycle. 4. A lot of this can be simplified using jQuery methods. Help yourself. <script type="text/javascript"> function setCookie(cookie_name, value, exdays) // props W3Schools { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var cookie_value = escape(value) + ( (exdays == null) ? "" : "; expires=" + exdate.toUTCString() ); document.cookie = cookie_name + "=" + cookie_value; } function getCookie(cookie_name) // props W3Schools { var cookie_value = document.cookie; var cookie_start = cookie_value.indexOf(" " + cookie_name + "="); if (cookie_start == -1) { cookie_start = cookie_value.indexOf(cookie_name + "="); } if (cookie_start == -1) { cookie_value = null; } else { cookie_start = cookie_value.indexOf("=", cookie_start) + 1; var cookie_end = cookie_value.indexOf(";", cookie_start); if (cookie_end == -1) { cookie_end = cookie_value.length; } cookie_value = unescape(cookie_value.substring(cookie_start, cookie_end)); } return cookie_value; } function shuffleArray (myArray) { // props Fisher-Yates var i = myArray.length, j, tempi, tempj; if ( i === 0 ) return false; while ( --i ) { j = Math.floor( Math.random() * ( i + 1 ) ); tempi = myArray[i]; tempj = myArray[j]; myArray[i] = tempj; myArray[j] = tempi; } return myArray; } if (!window.JSON) { // props Mozilla window.JSON = { parse: function (sJSON) { return eval("(" + sJSON + ")"); }, stringify: function (vContent) { if (vContent instanceof Object) { var sOutput = ""; if (vContent.constructor === Array) { for (var nId = 0; nId < vContent.length; sOutput += this.stringify(vContent[nId]) + ",", nId++); return "[" + sOutput.substr(0, sOutput.length - 1) + "]"; } if (vContent.toString !== Object.prototype.toString) { return "\"" + vContent.toString().replace(/"/g, "\\$&") + "\""; } for (var sProp in vContent) { sOutput += "\"" + sProp.replace(/"/g, "\\$&") + "\":" + this.stringify(vContent[sProp]) + ","; } return "{" + sOutput.substr(0, sOutput.length - 1) + "}"; } return typeof vContent === "string" ? "\"" + vContent.replace(/"/g, "\\$&") + "\"" : String(vContent); } }; } function getImage () { var theCookie, img, arr = getImageArray(); theCookie = getCookie("image_cookie"); if (!theCookie || theCookie == "[]") { arr = shuffleArray(arr); } else { arr = JSON.parse(theCookie); } img = arr.pop(); setCookie("image_cookie", JSON.stringify(arr), 365); // expires in 1 year return img; } function getImageArray () { var images = new Array(); images[0] = '<a href="page1.html"><img src="../../images/111.jpg" alt="aaa" title="test1"></a>'; images[1] = '<a href="page2.html"><img src="../../images/222.jpg" alt="bbb" title="test2"></a>'; images[2] = '<a href="page3.html"><img src="../../images/333.jpg" alt="ccc" title="test3"></a>'; images[3] = '<a href="page4.html"><img src="../../images/444.jpg" alt="ddd" title="test4"></a>'; images[4] = '<a href="page5.html"><img src="../../images/555.jpg" alt="eee" title="test5"></a>'; images[5] = '<a href="page6.html"><img src="../../images/666.jpg" alt="fff" title="test6"></a>'; images[6] = '<a href="page7.html"><img src="../../images/777.jpg" alt="ggg" title="test7"></a>'; images[7] = '<a href="page8.html"><img src="../../images/888.jpg" alt="hhh" title="test8"></a>'; return images; }</script> You can put that script in the head of your document or save it as an external file. Wherever you want the randomized image to appear, all you need is this: <script type="text/javascript"> document.write(getImage());</script>
  25. As to document.write, you have options. If you want to report values in response to a click or something, you can have a textarea and just update it's value. document.getElementById("ta").value += newValue + "\n"; // the newline lets you keep a running record or you could change the innerHTML of a div or <p> or something: document.getElementById("myDiv").innerHTML = newValue; If you want to create an element dynamically, look into document.createElement(). The big problem with document.write is that if you use it after the document loads, you will delete the entire document and start fresh. Usually that's not what people want.
×
×
  • Create New...