Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. $months = array( 1=>"January","February","March", "April","May","June", "July","August","September", "October","November","December" ); echo "<form action=\"process.php\" method=\"POST\">\n"; echo "<select name=\"month\">\n"; foreach ($months as $monthNum=>$monthName) { $selected = (date('n')==$monthNum) ? ' selected="selected"' : '' ; echo "<option value=\"{$monthNum}\"$selected>{$monthName}</option>\n"; } echo "</select>\n"; echo "</form>\n";
  2. MooTools is open source: http://mootools.net/
  3. As he said it is your call. Personally I would not store images in the database, only the path.
  4. Yes, it is JavaScript. If there were no JavaScript the page would "jump" to the anchor instead of having the smooth scoll effect. Just because there is no JavaScript trigger embedded directly in the links doesn't mean there is no JavaScript. You can add a JavaScript trigger to any element outside of the element itself. If fact in the head of the document there is this code <script type="text/javascript"> window.onDomReady(function(){ new SmoothScroll({duration: 1800}); }); </script> I would assume that the SmoothScroll object is in the included JS file 'mootools.js', but the author used some obfruscation on that and I'm too lazy to decode it.
  5. I'm pretty sure you have to use a GROUP BY with the MAX() function. And that won't help you in this case because you need other data from that row any way. Just order the results from highest to lowest and use LIMIT to get the top record SELECT invited_by, total FROM winner_tmp ORDER BY total DESC LIMIT 1
  6. Well OFF is fine if it has been defined as a constant. But, assuming that OFF is correct, there is an easier way to accomplish that: $rateme = ($_POST['add_type']==1 && $_POST['add_rateme']==OFF) ? 1 : 3;
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript"> function moveNext(fieldObj, nextFieldID) { if (fieldObj.value.length == fieldObj.maxLength) { document.getElementById(nextFieldID).focus(); } } </script> </head> <body> (<input type="text" name="phone1" id="phone1" size="3" maxlength="3" onkeyup="moveNext(this, 'phone2')">) - <input type="text" name="phone2" id="phone2" size="4" maxlength="4" onkeyup="moveNext(this, 'phone3')"> - <input type="text" name="phone3" id="phone3" size="4" maxlength="4"> </body> </html>
  8. I can't help without something to go on. Please post: 1) The enitre javascript output that is written to the HTML page - especially the array. 2) The Select and text field from the HTML Be sure to provide the rendered HTML not the PHP code.
  9. I think lemmin's right. Here is the utput I get with my test page when doing an autosubmit vs. a manual submit. Autosubmit: [myfreefo] => THEUSERNAME [password] => THEPASSWORD [redirect] => Manual Submit: [myfreefo] => THEUSERNAME [password] => THEPASSWORD [redirect] => [login] => Log in
  10. Hmmm, I did a simple test and it worked for me. <html> <head></head> <?php if ($_POST['myfreefo']) { //Display the results from the submitted data echo "Submit Data:<br>"; echo "<pre>"; print_r($_POST); echo "<pre>"; $onload=""; } else { //First page load auto-submit the data $onload = "javascript:document.forms.samsform.submit();"; } ?> <body onload="<?php echo $onload; ?>"> <form name="samsform" action="" method="post"> <input type="text" class="post" name="myfreefo" size="25" maxlength="40" value="THEUSERNAME" /> <input type="password" class="post" name="password" size="25" maxlength="32" value="THEPASSWORD" /> <input type="checkbox" name="autologin" /></span></td> <input type="hidden" name="redirect" value="" /><input type="submit" name="login" class="mainoption" value="Log in" /> </form> </body> </html>
  11. How can I do that? You have not provided any sample of the HTML code.
  12. Have you looked a the HTML that was produced when you used $item['Description']? Are you getting any errors? Is there is a single quote mark in the data which is breaking the javascript (would just need to escape them through PHP)? Please provide some details.
  13. What text? I'm assuming you don't meant the text in the input field since 2/3 of the validation is for when there is no text. So, I am guessing you are talking about the label. yes, that can be done, but if you make your FULL request up front it is more conducive to receiving the best response. Depending on how your labels and fields are constructed I might do things different than what I did above. please post the code for your form and I can assist.
  14. Yes. I think I already answered that. If you have a finite number of categories like you showed in your example, then three separate tables would be better (e.g. Make, Model, Sub-Model?). Because in that example each category is a unique type of entity (make = manufacturer of the car, model = type of car, etc.) however, with something like a geneology database youhave many parent/child combinations similar to many categories, but each entity is stil the same type of object (a person). Since you did not explain the type of records you plan to record I can't really provide any concrete advice.
  15. I'm not sure how to anser that. You gave your table structure and stated that you wanted to get the list of songs/mp3s for a particular singer. The query I provided will do that. Was that not what you wanted? I'm guessing you don't understand JOINS. This forum is not an appropriate palce to give a lesson on database joins, but there are plenty of tutorials on the net.
  16. You can do that first part (so id in product_orders would equal the id from the actual products table[/i]), but you will need to make sure that the id in product_orders is not unique. As for JOINS - well that is the true power of databases. It can take some time to understand them and, even then, there will be times where you will scratch your head to figure out the right query in difficult situations. But, whatever you do, don't use looping queries as I see many people do because they don't understnad how to do JOINS. Looping queries (i.e. do one query to get the parent records and then loop through the results to run individual queries on another table using the parent info) are extreemly inefficient and a hugh overhead.
  17. OK, one laast try. I think this is what you want: <?php error_reporting(E_ALL ^ E_WARNING); require_once ( 'settings.php' ); $count = $db->RecordCount("SELECT ID FROM Items"); $query = mysql_query("SELECT * FROM Items"); while ($item = mysql_fetch_array($query)) { $options .= "<option value='{$item['ID']}'>{$item['Name']}</option>"; $jsDescrAry .= " dscrList[{$item['ID']}] = '{$item['DEscription']}';\n"; } ?> <html> <head> <script type="text/javascript"> dscrList = new Array(); <?php echo $jsDescrAry; ?> function setVal(fieldID, inputID) { document.getElementById(fieldID).value = (dscrList[inputID] || ''); } </script> </head> <body> Country: <select name="thelist" onchange="setVal('thetext', this.value);"> <option value=""><--Select a Country--></option> <?php echo $options; ?> </select> <br /> Description: <input type="text" name="thetext" id="thetext" /> </body> </html> Also, it is bad practice to use short tags, i.e. <? as it is not supported on all server by default and can be a problem if you ever nee to move to another server.
  18. Go with Option C Create one table for purchase order data and a second table for the product data PO Table would have fields such as: id, PO #, Company, Paid, & date Product table would have fields such as: id, po_id, quantity When yu have a many-to-one relationship you need to have separate tables and the data needs to be captures in the appropriate table. For example if you want to capture the cost for a product it would be captures in the product table. But, if youhave a PO cost for shipping or taxes it should be captures at the PO level. You can then get any data you need by joining tables in your query. With the fields I had above if I needed to get the details of a purchase order I would run the following query SELECT * FROM purchase_orders JOIN products on purchase_orders.id = products.po_id
  19. I don't understand the need for a song table and an mp3 table. Wouldn't a song be the mp3? I guess you could have multiple versions of the song. Anyway, I interpreted the question as to how to show just the songs for a particular singer. based upon the table structure, the following query should get you all of the songs for the identified singer: SELECT * FROM songs JOIN mp3 ON songs.id = mp3.song_id JOIN singers ON songs.singer_id = singers.id WHERE singer.id = '$singer_id'
  20. If you are dealing with a finite number of sub-categories such as your example above, then separate tables make the most sense. Especially since each "category" may need different supporting information. However, if your subcategories will be infinite (such as a geneology solution) you will use one table. If this is the route you need to go, look for a tutorial - her is one: http://www.codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/
  21. function checkme_station() { stationObj = document.getElementById('station_name'); if (stationObj.value == "") { stationObj.style.borderColor = '#ff0000'; alert("Please enter a name for this station."); stationObj.focus(); return false; } selectionObj = document.getElementById('selection'); if (selectionObj.value == "Enter song or musician name" || selectionObj.value == "") { selectionObj.style.borderColor = '#ff0000'; alert("Please enter the name of the song or name of musician into selection field."); selectionObj.focus(); return false; } stationObj.style.borderColor = ''; selectionObj.style.borderColor = ''; return true; }
  22. This is more of a PHP (or server-side) question than a JavaScript question. You can write all the javascript you want and you are not going to have those votes saved and displayed to other users or to the same user on different visits. The client-side functionality is made up of simple FORMs with a single button and hidden field that get submitted to the server where the data is saved. <div class="vote-widget"> <div class="vote-count">13<span> votes</span></div> <div class="vote-actions"> <form action="http://www.mixx.com/vote/for/2011901" class="vote-for" method="post"> <input type="hidden" name="collection" value="1" /> <button type="submit" class="submit" title="Vote for"><span class="alt">Vote for</span></button> </form> <form action="http://www.mixx.com/vote/against/2011901" class="vote-against" method="post"> <input type="hidden" name="collection" value="1" /> <button type="submit" class="submit" title="Vote against"><span class="alt">Vote against</span></button> </form> </div> </div> The site then uses CSS to make those buttons appear as images. I don't see any javascript involved.
  23. OK, now I'm confused. You are using $item['Name'] as the "text" for the option and $item['ID'] as the "value" of the option. And you state you want to have $item['Name'] shown in the description field? If the user can see the 'Name" as the selected option in the select list, why is there a need to populate the same text into the description field? You could do that by changing the function as follows: function setVal(fieldID, inputObj) { selText = inputObj.options[inputObj.selectedIndex].text; document.getElementById(fieldID).value = selText; } And then changing the onchange call to this onchange="setVal('desc', this);" Is there, possibly, a description field in the database that is not included in the above code? That would change things.
  24. Give each secondary TR a unique ID and then call the function within the top TR passing the unique ID <html> <head> <script> function showHideTR(trID) { trObj = document.getElementById(trID); trObj.style.display = (trObj.style.display!='block') ? 'block' : 'none'; } </script> </head> <body> <table align="center" width="100%" class="tbl" border=1> <tr><td align="center" class="hdr" onclick="showHideTR('tbl-1');">.::Other::.</td></tr> <tr style='display:none;' id="tbl-1"><td align="left" class="tbl"> <a href="you.php" target="main">Your stats</a><br /> <a href="personal.php" target="main">Personal</a><br /> <a href="vote.php" target="main">Vote</a><br /> <a href="statistics.php" target="main">Game statistics</a><br /> <a href="notfinished.php" onclick="window.open(this.href, '_blank', 'width=500,height=700,scrollbars=yes,resizable=no,status=no,screenx=5,screeny=5');return false;" onkeypress="this.onclick()">FAQ</a><br /> <a href="abusereport.php" target="main"><font color="red">Report Abuse</font></a><br /> <a href="request.php" target="main"><font color="red">Parental control</font></a><br /> <a href="logout.php" target="main">Logout</a><br /> </td></tr> </table> <table align="center" width="100%" class="tbl" border=1> <tr><td align="center" class="hdr" onclick="showHideTR('tbl-2');">.::FUN AND SAFE::.</td></tr> <tr style='display:none;' id="tbl-2"><td align="left" class="tbl"> NY-Mobster is a fun place to be, but on<br /> top of that we aim to be the safest too!<br /> <br /> If you are a parent of a young person on<br /> NY-Mobster and have any concerns<br /> about the welfare of your child online,<br /> this is understandable.<br /> To combat this, you may join up then<br /> request parental controls, you may then<br /> monitor your childs messages to make<br /> sure you are happy!<br /> <br /> There is a staff member on most of the<br /> time to help solve any problems.<br /> <br /> We hope you enjoy NY mobster like<br /> many others!<br /> </td></tr> </table> </body> </html> You should consider adding a "pointer" mouse cursor to the 'hdr' class for usability.
  25. And your point is??? The code I provided will do what you want. You just need to create the select list accordingly when you do the db query. Here is a slightly modified version with the fields as you described: <html> <head> <script type="text/javascript"> function setVal(fieldID, inputValue) { document.getElementById(fieldID).value = inputValue; } </script> </head> <body> Country: <select name="thelist" onchange="setVal('thetext', this.value);"> <option value=""><--Select a Country--></option> <option value="Description of Romainia">Romania</option> <option value="Description of United States">United States</option> <option value="Description of Canada">Canada</option> </select> <br /> Description: <input type="text" name="thetext" id="thetext" /> </body> </html>
×
×
  • 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.