Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. I would not consider hitting the database to get an image reference an intensive operation. There are benefits and drawbacks to both methods you described. Only you can determine which is the most appropriate for your users. The best solution may be one or th eother - or even both! Refreshing the page for each image. Yes, this does require the page to be submitted to retrieve the next image. Resulting in a database call and a page refresh. Plus, fancy page transitions would still require JavaScript. Unless you have done some stress testing on your server you can't determine if this will have a negative impact on performance. The benefit of this solution is that it will work 100% of the time because it would be plain old HTML. Putting all images into a JavaScript Array This would require only once access to the DB to get all the images in the category and you could build in fancy transistions with the JS (however, you could still use transitions with the first method using onload, but it would have a page refresh). But, and this is a big one in my opinion, it relies on Javascript. So, you would effectively block any user that does not have JS enabled. That isn't a large percentage, but how many users are you willing to lose (don't forget about users who may be accessing via a device that is not a PC). Plus, you need to ensure the JS is interpreted correctly by all browsers. The third option is to build option #1, then layer Javascript on top. For example, go ahead and create the JS array and all the functions needed to run the images through JS. But, create the Next/Prev links as you would for option #1. Then have an onload function that will modify those links to call the JS functions instead of calling the HREF link. Then if the user does not have JS enabled the links will work. If the user has JS enabled then they get the JS version.
  2. Arrays that use a quote around the index aren't parsed correctly within double quotes. But, you can wrap the variable within brackets echo "<option value=\"please pick\" >{$_POST['month']}</option>"; I tend to wrap all my variables in brackets when they are included in strings with double quotes. Don't know why you are having the issue described above. Have you check the HTML output source for any clues?
  3. http://www.phpfreaks.com/forums/index.php/topic,223869.0.html
  4. LOL, that's my code! Anyway, which "subOption2" are you talking about? You have a "subOption2" for country, state & city. Would have been helpful if you had provided some real values. If you needed to display/hide based upon city country or state, you could do this: 1. First set the initial style for the field to visibility:hidden <input type="text" style="visibility:hidden;" name="dslam" id="dslam" class="textboxstyle" value="DSLAM Info" size="32" /> Then change the setStates function to change on country selection as follows (or setCity if changing based upon state): function setStates(){ cntrySel = document.getElementById('country'); stateSel = document.getElementById('state'); //<--START NEW CODE--> cntryValue = cntrySel[cntrySel.selectedIndex].value; inputVisability = (cntryValue=='SubOption2') ? '': 'hidden'; document.getElementById('dslam').style.visibility = inputVisability; //<--END NEW CODE--> stateList = states[cntrySel.value]; changeSelect(stateSel, stateList); setCities(); } ^^Not tested
  5. You would want to use server-side code (e.g. PHP) to write a JavaScript variable of the current server time. Then the JavaScript would increment that time as it runs.
  6. I already gave you the solution. You are not properly utilizing the variable passed to the function. If you put a varibale name within quotes, it is no longer a variable, it is a string. JavaScript does not interpret variables within a string like PHP does. Here is an example of what I mean function alertVariableNoQuotes(var) { alert(var); //This will alert the value of the variable passed to the function } function alertVariableWithQuotes(var) { alert("var"); //This will alert the string "var" } This line in your code mins = 1 * m("time"); // change minutes here interprets "time" as a sting, NOT the value of the variable time. You would need to remove the quotes, however there are other parts of your code that requires the variable to be a string. I decided just to rewite the whole thing var seconds = 0; var outputObj = false; function startTimer(startTime, timerOutputObj) { //Parse minutes and seconds into integers startTime = String(startTime); var mins = parseInt(startTime.split(':')[0]); if (isNaN(mins)) { mins = 0; } var secs = parseInt(startTime.split(':')[1]); if (isNaN(secs)) { secs = 0; } //Convert to seconds seconds = (mins * 60) + secs; outputObj = timerOutputObj; //Run the timer runTimer(outputObj); } function runTimer() { outputObj.value = formatTime(seconds); seconds--; if(seconds < 0) { window.alert("Time is up. Press OK to continue."); // change timeout message as required // window.location = "yourpage.htm" // redirects to specified page once timer ends and ok button is pressed } else { setTimeout('runTimer()', 1000); } } function formatTime(seconds) { var mins = Math.floor(seconds/60); if (mins<10) { mins = '0' + mins; } var secs = Math.round(seconds%60); if (secs<10) { secs = '0' + secs; } return (mins + ':' + secs); } You would call the function like this startTimer('5:30', document.cd.disp); The start time can be a string or a number.
  7. The options of sending read receipts are customizable in the email client and should not be used for verifying an email. I never send a read receipt when requested just out of habit.
  8. The line in which you use "time" you are using it as the string "time" and not the variable time. I'm assuming m() and s() are functions. function cd(time) { // You are passing the string "time" and not the var time mins = 1 * m("time"); // Passing a string here as well, but it includes numbers, //so it may be interpreted correctly secs = 0 + s(":01"); redo(); }
  9. The "best" way - in my opinion - would be to put the images into a database. You could then organize your photo albums and do things such add names, descriptions to the photos and even specify the order. But, if you are only making this a simple file driven system, then I would suggest putting all the images in the directory into an arry. Then use the array index to detemine the previous, current & next images. Here's a sample script. Just change the $directory to the path to a folder with jpg images. <?php $directory = 'images'; $imageList = glob("$directory/*.jpg"); $imgIndex = $_GET['img']; if(!isset($imageList[$imgIndex])) { $imgIndex = 0; } $currentImage = $imageList[$imgIndex]; if ($imgIndex<=0) { $prev = "Previous"; } else { $prev = "<a href=\"".$_SERVER[php_SELF]."?img=".($imgIndex-1)."\">Previous</a>"; } if ($imgIndex>=(count($imageList)-1)) { $next = "Next"; } else { $next = "<a href=\"".$_SERVER[php_SELF]."?img=".($imgIndex+1)."\">Next</a>"; } ?> <html> <body> <?php echo "$prev $next<br>"; echo "<img src=\"{$directory}/{$currentImage}\">"; ?> </body> </html>
  10. You should mark the topic as solved. Also, since I love compact code I will offer a couple modifications to what Permiso provided. 1. Increment the counter in the comparison, then you don't need the $i++; at the end. $color = (($i % 2) == 0)?"red":"blue"; 2. Even better, don't use the counter at all $color = ($color != 'red') ? 'red' : 'blue';
  11. You issue deal with variable scope. If you initialize a variable within a function, then that variable only has scope in that function. To make a variable have global scope, then declare it outside of the functions //Declare the variable var one; function one() { var one=1; } function two() { alert('value of one is '+one); } two(); //Will alert "Value of one is 1"
  12. JavaScript is not necessary, just have two submit buttons that pass different values to the processing page. Then include logic to perform the appropriate action based upon the button used to submit the form. Of course, you will need to determine a "default" action to take if the user submits via the enter key.
  13. <?php $row1 = mysql_fetch_array( $atable ); $avail = $row1['avail']; echo "<table>\n"; echo "<tr>\n"; echo "<th>Type</th>\n"; echo "<th>Units</th>\n"; echo "<th>Adults</th>\n"; echo "<th>Children</th>\n"; echo "<th>Minors</th>\n"; echo "<th>Availability</th>\n"; echo "<th>Price</th>\n"; echo "</tr>\n"; $recordset = explode(';',$avail); foreach ($recordset as $record) { $datarow = explode(',', $record); foreach ($datarow as $value) { echo "<tr>\n"; echo "<td>{$data[0]}</td>\n"; echo "<td>{$data[1]}</td>\n"; echo "<td>{$data[2]}</td>\n"; echo "<td>{$data[3]}</td>\n"; echo "<td>{$data[4]}</td>\n"; echo "<td>{$data[5]}</td>\n"; echo "<td>{$data[6]}</td>\n"; echo "</tr>\n"; } } echo "</table>\n"; ?>
  14. Well, I was able to rework this, but it seems to only work in IE, not FF - haven't tested other browsers. See if this is what you want. <!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 addComission() { //Reference to input form object var ifo = document.getElementById('input_form'); //Initialize variables var finalGP; var selectedQuantity = ifo.quantity.value; var selectedProduct = ifo.product.value; var selectedItem = ifo.itemComp.value; var selectedUnitPrice = ifo.unitPrice.value; var selectedQtyPrice = ifo.qtyPrice.value; //*********************** // NOTE: This function should have more validation & error handling //*********************** if (selectedUnitPrice=="0" || selectedUnitPrice=="") { finalGP = (selectedItem - selectedProduct) * selectedQuantity; } else { finalGP = (selectedItem - selectedProduct + selectedUnitPrice) * selectedQuantity; } finalUnit = selectedQuantity * selectedUnitPrice; ifo.qtyPrice.value = finalUnit; //ifo.gp.value = finalGP; // Get a reference to the table var tableRef = document.getElementById('commissionTable'); // Insert a row in the table at row index 0 var newRow = tableRef.insertRow(tableRef.rows.length); // Insert the cells right to left addValueField(newRow, 'gp', finalGP) addValueField(newRow, 'qprice', finalUnit) addValueField(newRow, 'uprice', selectedUnitPrice) addValueField(newRow, 'item', selectedItem) addValueField(newRow, 'prod', selectedProduct) addValueField(newRow, 'qty', selectedQuantity); //Remove values from the input form ifo.quantity.value = ''; ifo.product.value = ''; ifo.itemComp.value = ''; ifo.unitPrice.value = ''; ifo.qtyPrice.value = ''; } function addValueField(rowObj, fieldName, value) { var newCell = rowObj.insertCell(0); fieldName = fieldName + '[]'; var inputTxt = '<input type="text" name="'+fieldName+'" value="'+value+'"'; inputTxt += ' readonly="readonly" style="background-color:#cecece;width:50px;" />'; inputObj = document.createElement(inputTxt); newCell.appendChild(inputObj); return inputObj; } </script> <form name="input_form"> <table> <tr> <th>Qty</th> <th>Product</th> <th>Item</th> <th>Unit Price</th> <th>Qty Price</th> <th>&nbsp</th> </tr> <tr> <td><input name="quantity" type="text" size="6" value="1"/></td> <td> <select name="product" onchange="this.style.backgroundColor = '#FFCCCC'"> <option value=""> </option> <option value="1">add 1</option> <option value="2">add 2</option> <option value="3">add 3</option> <option value="4">add 4</option> <option value=""> </option> <option value="450">Nokia</option> </select> </td> <td> <select name="itemComp" onchange="this.style.backgroundColor = '#FFCCCC'"> <option value=""></option> <option value="340">Orange</option> </select> </td> <td><input name="unitPrice" type="text" size="14" value="0"/></td> <td><input name="qtyPrice" type="text" size="14" value="0"/></td> <td><button onclick="addComission()">Add Comission</button></td> </tr> </table> </form> <br><br>Commisions: <form name="commissioForm"> <table id="commissionTable"> <tr> <th>Qty</th> <th>Product</th> <th>Item</th> <th>Unit Price</th> <th>Qty Price</th> <th>GP</th> <th>&nbsp</th> </tr> </table> <button type="submit" id="submit">Submit Commisions</button> </form> </body> </html>
  15. Why have the user submit the form for every record? Just let the user add as many records as they want and then submit the form. I already ahve some code that does pretty mch what you want. Let me modify it closer to what you need. I'll post back in a bit.
  16. Not sure where your problem is. It looks like you are already creating the array and putting at least one value into it at the end of the first block of code. Just put the other values into the array as well. However, your second block of code is probably your problem. That code only runs before the page fully loads. Since, "f1Array" is declared in a function which would not have been run before the page fully loads, you won't get any output from that code. It would be helpful if you provided some more details about what you are trying to achieve.
  17. I get the first page of the modul when using that link. So, login has been removed. You definitely do NOT want to go with option 1. Even though you are trying to bypass security, you should never append the password in clear text. There were numerous options provided above that would give you the functionality you want with better security.
  18. Well, hell, there was a tutorial in Better Software magazine from a few years ago that I read which is exactly what you need. It was an AJAX tutorial using a chat application as the example. It was title "The Many Layers of AJAX". I still have that issue on my bookcase, unfortunately I can't find the article available online - unless you bug a subscription to stickyminds.com to see the archives. But, the basic premise is that you would use AJAX to send/recieve the data from the Client and Server. The clinet would simply have a timed event to check the server to see if there are any updates (i.e. posts by other users) and a client invoked even (onclick) to send updates from the user.
  19. Either you are not understanding the code provided int he otehr post or I am not undestanding you. Here is what I understood in your first post: You stated that you are displaying text which has been truncated and that upon clicking the "Read More" link the user is redirected to another page to read the entire text. instead you wnat the entire text to be displayed on the same page without a redirect. That is what I provided in the code in the other post I directed you to. The code snipped you posted above was the code to be run on the PHP side to determine what truncated and full text to be used. There is no splitting by HTML tags. You apparently already have code to truncate how you wish, so you would just need to use the code above as a guide to modify your current process. The full text needs to be split into the truncated and non-truncated text and put into DIV or SPAN containers, which the JS code will then use to display/hide the truncated text.
  20. I was assuming they would login. The title of this post is "How can we get passed the login page when using the URL?" Unless I am misreading it, it seems pretty clear from the OP's original post that they are trying to bypass the login process for users within that intranet to take them directly to the page in question.
  21. Take a look at this post from a few days ago. Several solutions are provided. http://www.phpfreaks.com/forums/index.php/topic,247661.0.html
  22. What you state does not make sense. You state that the highlighting needs to be account specific (but, you only have one record for the file). Does this mean that if file "foo.bar" has been downloaded by user A that the file will show as non-highlighted for him, but would be shown as highlighted for user B? Or is it that there are multiple users in an account? Or do you just determine if a file should be highlighted based upon if it has ever been downloaded? In any case, you should not have separate tables for the files. Just one table for the files is needed. I will explain three different scenarios and how you should handle. 1. If the highlight is determined based upon if the file has ever been downloaded by anyone Simply create a column in the files table to indicate if the file has been downloaded 2. If the highlight is based upon specific users and if each has ever downloaded the file Create another table with fileds for userID and fileID. you will then be able to determine whether to show a file as highlighted by joining the two tables 3. If the highlight is based upon whether any user from an account (where multiple users belong to an account) Use the same logic as #2. Create another table with columns for accountID and fileID. Then do an appropriate join based upon the user viewing the page to determine whetehr to highlight the file or not.
  23. And how, exactly, would you determine who the user is if they have not logged in? The options that come to mind are as follows: 1. Check the IP address/range of the user (assuming the people on this intranet have a dedicated IP address/range). If it is from that intranet log them into a guest account automatically with rights to that page. 2. If the users are storing the link to the page locally (on their PCs) and it is not available on the website, then append another parameter to the URL to detemine they are coming from that location.
  24. The function is returning false for me when using a space. Can you provide a working page with how you implemented the function?
  25. You're right. I've never seen any documentation that the comma works concatenate text the same as a period. Although it only seems to work within an echo and not for an assignment.
×
×
  • 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.