Jump to content

Psycho

Moderators
  • Posts

    12,164
  • Joined

  • Last visited

  • Days Won

    130

Everything posted by Psycho

  1. As I stated, the example I provided above works for me as expected. Did you try that example page or are you only trying in on your full page? If you are only trying it on your full page, there's a good possibility that there are some errors in your code. Please try the sample script I provided (if you have not done so already). If the sample page does not work as expected, what browser are you using? Have you tried different browsers. I can't help you when all you tell me is that it doesn't work - when it works correctly for me.
  2. FYI: There are a few things you should look into changing. 1. The mysql_ extentions have been deprecated for a long time now. Use mysqli_ or, better yet, PDO for DB operations. 2. Do not use "SELECT *". It may not be an issue in most cases, but it is bad form and could lead to security problems or bugs in some cases if you are not careful. It's always best to list out the fields you want. 3. There's no reason for creating all those temporary variables to get the datetime into the format you want. It's just adding unnecessary overhead. You could just do this: $notedateformat = date("n/j g:ia", strtotime($notesfill['note_date'])); or you could set the format is the SELECT parameters.
  3. There is no good solution for this. The browser is doing exactly what it should do. There are some things you can do to achieve what you want, but none are perfect. Here are some things you can do: 1. Use a table. You can try putting the buttons in the TDs and making their height 100%. I tried some variations with buttons and your CSS and didn't get good results. So, you could also use DIVs with an onclick event instead of the buttons 2. Use a fixed height DIV for the text inside the buttons. Use a height that will accommodate the the height needed for the button(s) with the most lines of text. This could be problematic if users have defined larger/smaller text sizes for their displays. 3. Use a fixed height for the buttons that will accommodate the one with the most lines of text. Has the same drawback as #2
  4. It works fine for me in Chrome (not tested in other browsers). - If the first field is "Yes" the second field is hidden and not required. I can submit the page without errors/warnings. - If I set the first field to No, then the 2nd field is displayed and IS required. If I attempt to submit w/o making a selection in the 2nd field, the browser displays a warning. If I make a selection in the 2nd field, then I can submit w/o errors/warnings. Here is my full test page <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script> $(document).ready(function (){ $("#JOBPRESENT1a").change(function() { if ($(this).val() == "No") { $("#jobfinish").show(); $("#JOBFINISH1a").prop('required', true); }else{ $("#jobfinish").hide(); $("#JOBFINISH1a").prop('required', false); } }); }); </script> </head> <body> <form method="post" action="" id="theform"> <label id='tooltip1'> Are you currently working with this company?<span></span><a>??<span>INFO</span></a></label><br /><br> <select id='JOBPRESENT1a' name='JOBPRESENT1a'><br> <option value='Yes'>Yes</option> <option value='No'>No</option><label> </select><br> <p id="jobfinish" style="display:none;"> <label id='tooltip1'> Which year did you finish working with this company?<span></span><a>??<span>INFO</span></a></label><br /><br> <select id='JOBFINISH1a' name='JOBFINISH1a'><br> <option value=''>Which Year</option> <option value='2020'>2020</option> <option value='2019'>2019</option> <option value='2018'>2018</option> <option value='2017'>2017</option> <option value='2016'>2016</option> <option value='2015'>2015</option> <option value='2014'>2014</option> <option value='2013'>2013</option> <option value='2012'>2012</option> <option value='2011'>2011</option> <option value='2010'>2010</option> <option value='2009'>2009</option> <option value='2008'>2008</option> <option value='2007'>2007</option> <option value='2006'>2006</option> <option value='2005'>2005</option> <option value='2004'>2004</option> <option value='2003'>2003</option> <option value='2002'>2002</option> <option value='2001'>2001</option> <option value='2000'>2000</option> </select><br> </p> <br> <button type="submit">Submit</button> </form> </body> </html>
  5. OP: 1. Since the initial value for the 'JOBPRESENT1a' field is yes, remove the required attribute from the 'JOBFINISH1a' field. 2. Change the function to show/hide the 'JOBFINISH1a' field to this $(document).ready(function (){ $("#JOBPRESENT1a").change(function() { if ($(this).val() == "No") { $("#jobfinish").show(); $("#JOBFINISH1a").prop('required', true); }else{ $("#jobfinish").hide(); $("#JOBFINISH1a").prop('required', false); } }); });
  6. Ah, thanks. As this was a JS question, I assumed the validation was JS related and didn't look for that.
  7. There is nothing in the code you have provided that makes any fields required. The only thing the code you provided does is hide/display the second field. Based on your comments there is some code somewhere to check for required fields. You should have logic that is implemented server-side (i.e. PHP), but you can also add logic client-side (i.e. JavaScript) for usability. You need to provide the code you already have to perform the validation in question in order for us to help. But, on a general level it would probably look something like this if($JOBPRESENT1a=='no' && $JOBFINISH1a=='') { //Error: If you are no longer working for the company, the year you left is required }
  8. You start by talking about two tables (ex order and order_detail), but the query you've provided has neither table listed. So, I'm not sure what you are wanting. Looking at the query you provided, it's difficult to understand since the names are not in English. The example results you've provided have the same data in all columns except the last. I presume that the columns with the same data are specific to the "order" whereas the last column is the name of the products in the order. If that is the case, then the results are exactly how you would want them to be returned. You don't set up queries to return data constructed for output. That is the job of the code that processes the data. So, if you wanted to create an invoice from that result set, it might look something like this: //Parse all return data into logical array $reservationsAry = array(); while($row = mysqli_fetch_array($result, MYSQLI_ASSOC) { $reservationID = $row['dreserva']; if(!isset($reservationsAry[$reservationID])) { $reservationsAry[$reservationID]['room'] = $row['sala']; $reservationsAry[$reservationID]['date'] = $row['data']; $reservationsAry[$reservationID]['timeStart'] = $row['inicio']; $reservationsAry[$reservationID]['timeEnd'] = $row['fim']; $reservationsAry[$reservationID]['items'] = array(); } //Add product $reservationsAry[$reservationID]['items'][] = $row['nome']; } //Output the data in appropriate format foreach($reservationsAry as $reservationID => $reservation) { echo "Reservation ID: {$reservationID}<br>\n"; echo "Room: {$reservation['room']}<br>\n"; echo "Date: {$reservation['date']}<br>\n"; echo "Start Time: {$reservation['timeStart']}<br>\n"; echo "End Time: {$reservation['timeEnd']}<br>\n"; echo "Items:<br>\n"; echo "<ul><li>" . implode("</li>\n<li>", $reservation['items']) . "</li></ul>"; echo "<br><br><br>\n"; }
  9. You could set the initial hide/show state on page load using PHP, but you would still have to set/remove the cookie in JavaScript since that action is taking place client-side. Well, technically, you could have a JavaScript call that uses PHP to set/remove the cookie, but it would still have to be initiated in JS.
  10. This works but . . . if the initial state should be to be collapsed there will be a short execution of the collapse functionality on page load <script> $(document).ready(function (){ //Action for priomary expand/collapse button $(".expshow").click(function(event) { $(this).parent(".expToggle").children("div.info").slideToggle(300); if($(this).text() == '[+]') { $(this).text('[-]'); //Create expand cookie document.cookie = "expand=1;expires=Thu, 31 Dec 2020 12:00:00 UTC"; } else { $(this).text('[+]'); //Delete expand cookie document.cookie = "expand=;"; } }); //Action for secondary collapse button $(".expless").click(function(event) { $(".expshow").click(); }); //On load, check if expand cookie is set. //If not, execute click event to hide div if(document.cookie.indexOf("expand=1") == -1) { $(".expshow").click(); } }); </script>
  11. My understanding is that if you Like the site on Facebook and get your friends to like it, you will get $100 for each of the friends. Plus, you will get another $50 for each of their friends that they get to like the site. You can get up to $50,000 per person. I've checked this out and it's legit. I mean it - it's really real. Oh, wait a sec, maybe it was a free trip for four to Disney World. No that's not it. The truth is that I am a a Nigerian Price that masquerades as as hobbyist programmer and I have US 50,000,000 (fifty million) US dollars tied up in an account that I need assistance in retrieving since I no longer have residence in my home country. I just need you to provide my your bank account information, passwords, social security number and mother's maiden name so that we can transfer the funds into your account. For your trouble, I will give you 10% of the proceeds (five million US dollars). Please keep this confidential and please hurry as time is of the essence.
  12. I don't know if there was one previously. The site is a "for profit" site that . The Staff (Moderators, Admins & Gurus) who run the site and answer the majority of the questions are all volunteers. Without going into too much detail, the Ownership and the Staff had little to no interaction. The reason for the recent, extended outage was due to a change in ownership that was not handled well (understatement). So, if you want to donate, determine who or what you are wanting to support. If someone provide a solution or help and you would like to thank them, you can reach out to them directly to donate to them. If you want to donate to the new business that now owns the site, they may implement something at some point.
  13. That's debatable. JK
  14. You can never assume that the value is not tampered with. So, even if you obfuscate the ID by using a GUID/Hash you still must ensure the user requesting the record is authorized and/or that the value is appropriate. Having said that, using a non-consecutive arbitrary value is still a good idea as the IDs can "leak" information as you indicated. I know that in our enterprise level application, many records have both an int ID as well as a GUID. The GUID is used as the identifier between the client and the server whereas the ID is used for internal operations (e.g. the PK/FK for JOINing tables). For most purposes, I agree with Jacques1 that just using a GUID instead of an ID will suffice. The main benefits of having both is that performance with INTs is typically faster and in high utilization scenarios every resource counts. This page has an informative table about 1/2 way down comparing different properties of four different ways of storing unique IDs. It's specific to MS SQL, but I assume most would correspond to MySQL as well.
  15. It was not by choice. There is new ownership which we are optimistic will help to advance the site.
  16. <?php ini_set('max_execution_time', 0); //Define the number of grids per row - used to dynamically open/close TRs $gridsPerRow = 2; $quest = array ( "TL" => array ( array(2,2,2,2), array ( 2,2,2,2), array ( 2,2,2,2) , array ( 2,2,2,2) ) , "TR" => array ( array(2,2,2,2), array ( 2,2,2,2), array ( 2,2,2,2) , array ( 2,2,2,2) ) , "BL" => array (array(2,2,2,2), array ( 2,2,2,2), array ( 2,2,2,2) , array ( 2,2,2,2) ) , "BR" => array (array(2,2,2,2), array ( 2,2,2,2), array ( 2,2,2,2) , array ( 2,2,2,2) ) ); function outputGrid($gridArray) { //Get count of total elements $totalElements = 0; foreach($gridArray as $dataArray) { $totalElements += count($dataArray); } //Create an array of the total count of elements $elementIndexesAry = range(1, $totalElements); //Randomize the list shuffle($elementIndexesAry); //Pick 5-10 elements $randIndexes = array_slice($elementIndexesAry, 0, rand(5, 10)); $gridOutput = "<table>\n"; $index = 0; foreach($gridArray as $dataArray) { $gridOutput .= "<tr>\n"; foreach($dataArray as $data) { //Increae the index $index++; //Determine the class based on current index $class = (in_array($index, $randIndexes)) ? "paint" : ""; //Output the cell $gridOutput .= "<td class=\"{$class}\">{$data}</td>\n"; } $gridOutput .= "</tr>\n"; } $gridOutput .= "</table>\n"; return $gridOutput; } $output = ''; $output .= "<table>"; $gridCount = 0; foreach($quest as $keyOut=>$gridData) { //Increase count $gridCount++; //If first record in row - open TR if($gridCount % $gridsPerRow == 1) { $output .= "<tr>"; } $output .= "<td>\n"; $output .= outputGrid($gridData); $output .= "</td>\n"; //If last record in row - close TR if($gridCount % $gridsPerRow == 0) { $output .= "</tr>\n"; } } $output .= "</table>"; $output .= outputGrid($quest["TL"]); ?> <!DOCTYPE HTML> <html> <head> <title>Arrays -1- </title> <style> table { width: 200px; height:200px margin: 15px; border-collapse: collapse; border: 2px solid black; } tr,td{ height: 50px; } td{ border: 1px solid gray; width: 100px; vertical-align: middle; text-align: center; } .paint{ z-index:3; background-color: pink; } </style> </head> <body> <?php echo $output; ?> </body> </html>
  17. Just because you don't have access to the back-end where the options originate from does not mean you cannot retrieve and format the options on your back-end. That most likely the reason why you are having trouble loading the lists on a mobile device because they do not have the same processing power of a normal PC. You should not push so much processing requirements on the user's system. Here is what I propose: First: If your page is not already a PHP (or other server-side page), convert it to one now. Even if there is no PHP code now and it is just an HTML page, it will still load fine when renamed to a PHP file. Although, this does require that the web server supports processing of PHP pages. Second, put a small bit of PHP code at the top of the page to retrieve the options from wherever the Javascript is getting the data from. Then use PHP to convert the options into the format you need. Lastly, add the reformatted options to the output and remove all the Javascript to dynamically create the options from the external lists. EDIT: With the chained selects, the processing needed to switch out the values may still be too much. If so, then you should do an AJAX call to get the list for a child select list when the parent is changed.
  18. No idea. I am unable to reproduce that error when using only some of the fields defined in the fulltext index. But, based on the comments in this post, the search must use the same columns in the same order as defined in the index. However, I don't see any reason why you can't define multiple fulltext indexes for the same table using different combinations of fields.
  19. I wasn't judging anyone, I was judging the process. OK, I'll admit there may be an edge case where the original proposed solution could be valid, but it would be a very, very narrow case. Even if one of the above were true, the primary purpose of a form is to send data to some resource to be acted upon. If the OP is sending the data to a page which he controls, then a JS solution is still a bad idea. So, the only logical use case I can think of where this would make sense is if all of the following are true: The options are being loaded via an external source (e.g. AJAX) which the OP does not control The form is being sent to a page the OP does not control The page is not generated via server-side code and the OP does not have the ability to use server-side code
  20. Maybe I am not understanding. Are the double quotes supposed to be part of the text to be compared against or are you intending for them to be delimiters? If the double quotes are meant to be part of the text to be compared against, then you can escape them (using a backslash). value = odbcconnectSQL("select MATCH(product_group) AGAINST ( '\"+shrimp +(export OR import) \"' IN BOOLEAN MODE) as score from company_info WHERE isin='abcd' AND MATCH(industry, product_group, products, raw_material, business_desc, gisc_ind_2) AGAINST ( '\"+shrimp +(export OR import) \"' IN BOOLEAN MODE) "); But, if you are wanting to use the double quotes as a delimiter for the string, I'm not understanding why since the single quotes would work just fine.
  21. If it is a static page, then it would be stupid to "fix" the values with javascript every time the page is loaded. If it is a static page then the values should be fixed permanently in the HTML code - one time. Even if there were a few hundred options, it wouldn't take that long to fix the values one time in the HTML code. There are plenty of ways to semi-automate it. For example, I could copy/paste all the options into Excel and reformat all of them in less than 5 minutes. If the values are dynamically created (such as with PHP), then the values should be modified on the server-side instead of introducing unnecessary client-side code.
  22. That why you would put a unique constraint on the dart_matches table. Since you are using the date to associate records, I suppose you could index the date fields. Never used date fields for indexing, but if you are going to use it for JOINing (as opposed to an INT field) then you should index it.
  23. Unless I missed something in your flurry of recent posts, you had [correctly] changed the names of the checkboxes to be an array in the format: defid[1], defid[2], defid[3], etc. But, your code now is trying to reference non-array fields in the format defid_1, defid_2, etc. You should simply need to iterate over the array using a foreach() loop. Something like: if(isset($_GET['defid'])) { //Define the query ONE time - then run multiple times $sql="INSERT INTO modified_adjustments (default_id) VALUES (:did)"; foreach($_GET['defid'] as $did) { $conn->query($sql, $params=array(':did'=>$did)); } }
  24. left outer join dart_match_scores as s1 on s1.Player_no = a.Player1 and s1.Match_date = $qdate left outer join dart_match_scores as s2 on s2.Player_no = a.Player2 and s2.Match_date = $qdate where a.Match_date = $qdate The variable $qdate in the JOIN criteria for those two tables is unnecessary and only complicates the query. Since the date in the "Match_date" table needs to be the same as in the "dart_matches" table you should just do this left outer join dart_match_scores as s1 on s1.Player_no = a.Player1 and s1.Match_date = a.Match_date left outer join dart_match_scores as s2 on s2.Player_no = a.Player2 and s2.Match_date = a.Match_date where a.Match_date = $qdate But, again, the match date is a poor choice for associating records. It should only exist in the dart_matches table and that table should have a unique ID field to be used as a foreign key in these associated tables.
  25. Give this a try. I guessed on the field name 'score' in the select list as the field name from the dart_match_scores table. I would also state that using the match date as the foreign key is a bad idea. I would suggest having a unique identifier in the dart_matches table and using that as the foreign key in any associated tables. As it stands now, a player could not have two matches on the same date. That may be something that shouldn't occur, but the database structure shouldn't be dependent on it. SELECT date_format(m.Match_date,'%m/%d/%y') as Match_date, m.Team_no, m.Player1, p1.Last_Name as p1ln, p1.First_name as p1fn, s1.score, m.Player2, p2.Last_name as p2ln, p2.First_name as p2fn, s2.score FROM dart_matches m -- JOIN to get player 1 name data JOIN voorhees_data.MMS_Members as p1 ON m.Player1 = p1.Roster_no -- JOIN to get player 1 score data LEFT OUTER JOIN dart_match_scores AS s1 ON m.Player1 = s1.Player_no AND s1.Match_date = m.Match_date -- JOIN to get player 2 name data JOIN voorhees_data.MMS_Members as p2 ON m.Player2 = p2.Roster_no -- JOIN to get player 2 score data LEFT OUTER JOIN dart_match_scores AS s1 ON m.Player2 = s2.Player_no AND s2.Match_date = m.Match_date WHERE m.Match_date = $qdate ORDER BY m.Team_no
×
×
  • 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.