Jump to content

Thierry

Members
  • Posts

    85
  • Joined

  • Last visited

    Never

Everything posted by Thierry

  1. I need the user to be able to select various items by holding down the mouse button and the hovering over the items (drag). Basicly, all I need is a check that verifies if the user is holding the mouse button down while it is hovering over the item, if it is, it will run the function. I thought it was simple but I cant get it to work, though its probably simple. Any ideas?
  2. I have a form in which several fields share the same name via an array (<input name="cookie[]" id="cookie[]">). I've been trying to use 'document.getElementById("cookie")[0]' and also 'document.getElementById("cookie[0]")', but neither yield any results. Anyway of getting the field object while its a form array? (The error I get: "Object expected");
  3. I'm getting my hand at AJAX and I've got a small problem. I'm simply using AJAX to test a request to the contents from an XML document and in Firefox it works perfectly, but in IE the contents never update, but they do in Firefox. As I'm new with AJAX its probably a small issue but I can't seem to find it. <html> <head> <title>AJAX test</title> <script language="javascript"> <!-- function data_request(url) { var httpRequest = ""; if(!(window.XMLHttpRequest == null)){ // Mozilla, Safari, ... httpRequest = new XMLHttpRequest(); //if we dont have a Content Type (format), we make it XML if(!(httpRequest.overrideMimeType == null)){ httpRequest.overrideMimeType('text/xml');} //attempt 1 for IE }else if(!(window.ActiveXObject == null)) { // IE try{ httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); httpRequest.setHeader("Cache-Control", "no-cache");} //attempt 2 for IE catch(e){ try{httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); httpRequest.setHeader("Cache-Control", "no-cache");} catch(e){}} } //end of if else //if we can't create the XML request, we end if(!httpRequest){ alert('Giving up Cannot create an XMLHTTP instance'); return false;} //ok, now we are gonna do our thing and then send the request httpRequest.onreadystatechange = function(){alertContents(httpRequest);} httpRequest.open('GET', url, true); httpRequest.send(''); //and our thing function alertContents(httpRequest) { //ready state values: // 0 (uninitialized) // 1 (loading) // 2 (loaded) // 3 (interactive) // 4 (complete) if(httpRequest.readyState == 4){ //status code of the HTTP server response, 200 is ok to go if (httpRequest.status == 200){ var xmldoc = httpRequest.responseXML; var root_node = xmldoc.getElementsByTagName('root').item(0); alert(root_node.firstChild.data);}else{ alert('There was a problem with the request.');}} } //end of alertContents } //end of data_request --> </script> </head> <input type="button" name="test" id="test" value="Test" onclick="data_request('testing.xml')"> <body> </body> </html> Any hint of what I'm doing wrong? (it works fine in Firefox 2.0)
  4. I have a dropdown in a form, and based on what you select in that dropdown, another dropdown can contain various options. I'm using the script below but it gives the "not supported by this object" error, although it does manage to create the first option succesfully, but none of the others. $counter = 0; while($row = mssql_fetch_array($result)){ $uur_id = $row["uur_id"]; $uur_naam = $row["uur_naam"]; if($counter == 0){ ?> <script language="Javascript"> <!-- var dropdown = parent.document.getElementById("uur_id"); var keuzevak = new Option; <? } ?> keuzevak.text = "<? echo $uur_naam; ?>"; keuzevak.value = "<? echo $uur_id; ?>"; dropdown.options[<? echo $counter; ?>] = keuzevak; <? ++$counter;} ?> --> </script> Any idea what I'm doing wrong? EDIT: Never mind, forgot to put the New Option part within the loop.
  5. Might be easier to just use a single field for all the holes, and put the data there as a single string. For instance, in hole 1 you have a score of 3, then 8 for hole 2 and 5 for hole 3, it would be put in the database as 3,8,5 and you could use the explode() function to make it an array again. Right now, you'd simply have to do it like this: $scores = $_POST["score"]; $hole_1_score = $scores[0]; $hole_2_score = $scores[1]; $hole_3_score = $scores[2]; //etc... The same would apply for your query, having to write down each separate field name.
  6. Wouldn't this work with the code first posted?? <a onclick="buttonDown('button')"><div id="button"></a>
  7. I use javascript instead of COM, reading the contents of the document into a reasonbly good string (without most of the document encoding). It only works for Word documents so far, so I dont know about the other ones.
  8. Hmm, a newline is made with \r\n, I'm geussing that you are removing the slashes from it. For textareas and such, \r\n is used, but for showing it otherwise you can use <br>. Try: $comments = str_replace("\r\n","<br>");
  9. Wouldn't it simply work to put the two variables behind one another? $web_date_time = "$web_date$web_time";
  10. Not sure how I could succesfully do that at this point. I have 5000 persons in my database, each with completely unique information. They do have a few status data that others have as well, but I still dont see how I could search by those instead of IDs.
  11. Thats not the problem. I cant use WHERE id > '0' AND id < '6' because that wouldn't work if I want to show id 1,3,5 but not id 2 and 4. Also, its not at all related to the fields with * (which I dont use).
  12. Its not the searching in the database that's the problem, its showing all the ids. For instance, I could (in theory) have record 1,3,5,7,9 and then all the way to 5000. The only way in which it could show all the ids then would be by using "OR id = '1' OR id = '3' etc". I suppose I could do it differently, running a thousand queries with one id (using a loop) then one query with a thousand ids but I think that would be very slow loading.
  13. I'm trying to use RTF files to generate my word documents instead of COM, due to it being faster and more compatible with other systems. However I haven't been able to get any kind of style to work in the document, it just displays everything including all the tags. <? //get the template $template_file = "template.rtf"; $template_content = file_get_contents($template_file); //make a temporary file, so we dont edit the original template $new_temp = "new_document.rtf"; $new_temp_file = fopen($new_temp,"w"); $new_content = fwrite($new_temp_file,$template_content); fclose($new_temp_file); //get the contents of our newly created temp file and edit it $content = file_get_contents($new_temp); $content = str_replace("*TEXT*","Line1<br>Line2<br>Line3",$content); //and save it over the temp file $new_file = fopen($new_temp,"w"); $new_file_content = fwrite($new_file,$content); fclose($new_file); ?> But instead of showing: Line1 Line2 Line3 It shows Line1<br>Line2<br>Line3 I tried using \r\n to no avail. Any idea what I'm doing wrong?
  14. I have several images over which I can hover, each having their unique id. When I hover over image 1 and then over image 2, I want to be able to have a variable which holds the previously hovered image (in this example, image 1) I thought it would be simple but it seems to be more difficult. function hover_country(id){ window.alert("You hovered over "+id); window.alert("You last hovered over "+previous_id); var previous_id = id; Basicly, the second time you hover over an image, shouldn't it give me the id of the previous one?
  15. I have a table with about 5000 records in it and roughly 50 fields, all with a lot of data in them. Naturally you can search in that table, but sometimes the results seem to be more then SQL can handle, the limit seems to be around 2000 records. Its not a question of getting the information, but having 2000 times an "OR id = '$id'" in the query. Right now I can't think of an alternative to get all the possible returned records, since it could be anywhere between zero and 5000. Any ways to get all the record id's without overloading the query with OR's?
  16. I suppose a possible option is to generate all those points by using a 1x1 pixel sized image (black dot) and giving it style="position: absolute; left=Xcoordinate; top=Ycoordinate". Not sure though.
  17. Don't make it $array = array($_POST['area']); Its already an array, you only need: $array = $_POST['area'];
  18. Make sure the first value used in the foreach (the $array) has the contents of your multi select box by giving them the same name in the select box and the $_POST. This means that the name and id below <select name="whatever[]" id="whatever[]"> Have to match the giving $_POST variable: $array = $_POST["whatever"] Don't forget to add the "[]" behind the names in your select box, only there.
  19. I'm sure freelancebusinessman's clients would love reading this stuff! Yeh cus planning is for pussies
  20. Hmmm, try adding this above the foreach: $string_to_db = ""; $separator = "";
  21. Might be better to use two images in two TD cells, the left cell have its image aligned to the right and the right cell having its image aligned to left.
  22. An array is a list of items, but stored in a single variable. To get to all the items in the array, you need to use various methods of getting each one. Using foreach or a while are the easiest ways. The foreach I made above will loop through each item (the selected items from your multi select box) and put them in a single piece of text. For example, a user selects "Germany" and "England" and "France". The foreach loop I made above will put all those in a single string, which should look like: "Germany,England,France". That's what you put in the database, and if you want to put it back into an array when you retrieve it from the database, the explode(); function above will do just that. Also, don't forget about http://www.php.net, they got a lot of stuff on Arrays.
  23. Your results with come in the $_POST as an array. Since storing as an array in the same way as php in a database doesn't work, I generally use a character in between all the values, and use that character to make it an array again using explode when I need it. $array = $_POST["name"]; $counter = 0; foreach($array as $item){ //you can use any character you want, I'll use a comma for this example if($counter <> 0){$separator = ",";} $string_to_db .= "$separator$item"; ++$counter;} When you want to make it back into an array after retrieving it from the database, simply use: $array = explode(",",$row["string_from_db"]); Again, you can use any other character besides ",".
  24. Nah its only for internal use in a network so that's not a problem.
×
×
  • 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.