last day (15 days later) » 

6:13 PM
-1
A: Form if then Else/ifElse HTML on submit

SonnYYou cannot mix PHP with JavaScript and why you set a timeout to 1000*30, that is equal to set a timeout to 30000 which means 30 seconds. Then, you can use the 'require' attribute in the input filed to force the user to fill the required information. <!DOCTYPE html> <html> <head> <meta name="Ware...

 
Hey @SonnY no need for that kind of language. That had already been pointed out in an above comment. Also I realize you can't combine them.. I'm looking for this type of If/then statement. I never said my code was right, I asked for help because I was aware my code wasn't working and I am loosing sanity working on the same issue for 3+ days when I know there has to be a logical way to accomplish this task. I want the times for 30 seconds. You need to read the question again to grasp what I am trying to accomplish here.
 
Ok, in this case I hope my solution will drive you to the right direction. Have a look at the code and see if it works
 
I don't want to force them to add information. I want them to have the opportunity to add 2 text values to indicate what they want those parts for and where they are taking them. If they don't I want it to time out after 30 seconds (an eternity for someone to input information) and then send that information to the database. I also want this to then move on beyond my ajax page and go back to the index page (where the form is located).
 
Ok, I reviewed my previous post. Now, if the 2 textfileds are empty, the form is submitted after 30 seconds. Let me know if that is what you were looking for
@SheaPrice, did that solve your problem?
 
I got excited that this would work flawlessly but unfortunately it makes me run into my previous issue... If I use the code this way it ends up generating ALL of the equipment ID's and not just the ones I took out. This issue happens when someone, for example brings a piece of equipment back that they ended up not needing for a job. Thanks for the idea!
 
6:13 PM
@SheaPrice right, that is because all the imput in the foreach statement have the same id. We're close to the solution then. The problem now is that you have 1 forn containing all the input fields so, when you submit the form, it submit all the input values. You can include the form inside the foreach and submit only the one the user is editing
 
Can you please explain, I have another issue with the foreach statement according to another user. I can't send multiple values through, say user has 2+ pieces of equipment and different text inputs it will only accept the first one (stackoverflow.com/questions/34456073/…).
I tried adjusting this but the page also had issues with my adjustments. I tried troubleshooting that for a few weeks and pushed it off to my "later to-do list". You can see I've modified a lot of my code, but still need a better understanding of all of these languages to understand where I am goofing up.
 
hi
 
Hi, SO told me we should move this conversation to chat
 
I'm trying to reproduce your environment but I need some missing information regarding the $results array
 
Okay, heads up this is grabbing information from an application(live data) parsing it and injecting information into the application to finish it's way to the DB
<?php

$application_ip = “XXXXX”;

$post = [
'submit' => 'true',
'activity_name' => 'GetDBReportMsg',
'params' => [
'CustomData' => '',
'SendToSema' => '0'
]
];

$result = "";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://".$app_ip."/index.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));

if (isset($_POST['DONE']) === true) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
 
6:25 PM
ok but I still don't know the content of the returned $results object
can you paste me in the structure of the returned object?
 
Oh you mean the raw unparsed data structure?
 
yes
I need to recreate the table with the foreach loop
 
{
"messagetype": "Transaction",
"companyname": "C01",
"warehousename": "W01",
"dir": "OUT",
"date": "2016-1-03 12:24:51.024",
"tags"; [
{"category": "Employee", "company": "00011", "user": "TT", "type": "1"},
{"category": “equipment”, "number": “D00579”, “amount”: "1"},
{"category": “equipment”, "number": “C00336”, “amount”: "1"}
]
}
 
give me 2 minutes
 
Ok thanks
 
6:36 PM
there are no category=part in that raw
 
the data use to come through as {"category": "Part", "number": "D00378", "amount": "1"}
 
but doesn't matter. I have the table rendered now
what you want to do exactly?
the button DONE works fine?
 
yes the Done button works great
 
ok
so, wat exactly you want to send after 30 seconds?
 
I need the user to be able to bring equipment in, leave, and when the form auto-resreshes there needs to be nothing that shows up. If they just come in to grab parts I need the form to auto-generate the parsed out information and the should be able to put information in if they need to and hit done. If they don't enter any information it needs to go ahead and send through to the database
 
6:42 PM
I don't understand why you need to subit the information to the database if they don't hit the button
 
Because we still need the database to register that those parts have left the warehouse
 
but then you should implement a confirmation button after each text field to confirm the update
 
Why? Warehouse users generally aren't computer savvy so the less they do on it the better
 
but why putting a timeout?
what they write in the input fields?
 
The timeout button is incase they leave without hitting the done button with equipment in tow, we need our records to reflect the correct amount of items in the warehouse. Input fields are if they do what they are suppose to and tell us where the equipment is going. If they don't and walk out at least we have record of the equipment leaving.
Otherwise it may generate those equipment pieces to the next person who walks out with equipment
 
6:49 PM
ok, in this case you need a timeout loop instead of a single timeout after 30 seconds?
you need to submit all the changes, if any, every 30 seconds?
 
Oooh is that what I need?
Yes that is correct!
 
ok
but what is wrong with submitting all the input fields?
that should be the best solution
 
I am fine with all input fields being submitted, but I don't trust people to do their job because they rarely do
 
but you said: If I use the code this way it ends up generating ALL of the equipment ID's and not just the ones I took out.
that should be fine, and you need to compare the received information with the one present in the database and find if there is something different
 
Oh, that will pull up all of the equipment pieces not in the read zone, just the entire list of the ones that have come through that day... this is very problematic. I don't want it to recall all the equipment, it should be blank since they user isn't coming out with any
 
6:53 PM
but that should be done in ajax.php
hm ok
let me think then
 
Well I do have an ajax.php
 
ok maybe I have a solution
but I don't know how you update the information in ajax.php
do you have a product id for updating the database information?
is that the part number?
 
Okay I am all ears...
$dataString = "val1=" . $_POST['val1'] . ",val2=" . $_POST['val2'];

// set post fields
$post = [
'submit' => 'true',
'activity_name' => 'DataSend',
'params' => [
'Data' => $dataString
]
];
 
but how you know which item you want to update in the database?
you only have 2 values but no reference to the product
 
So again I Frankensteined this code so I'm looking at my notes to see if I understand and how to answer
 
7:02 PM
if you send to ajax.php 2 values is not enough for updating the database information
you should have a product id or something like that
 
It is. If someone just takes equipment and leaves the database updates without the added information. I believe it comes from the foreach statement
 
but what you need to send to ajax.php to update the product information???
is that the part number?
 
I guess... I'm not really sure.
I think the $equipment tag that relays to the category and Part is what works.
Sorry, I'm struggling to grasp this
 
7:18 PM
almost done
but I don't know how that will work on the server side
 
Understandable, I'm not much help since I don't understand what I'm doing. For the most part I've built this blind which is probably why I keep running into issues
 
I posted the new code in the discussion. have a look and let me know
can you also please remove that -1 on my previous comment?
I don't think I really deserve that
 
I didn't do that
Yes I will look at the code, if you can tell me how to see which user left that I'd be happy to
Thanks again
 
I don't think it's possible to know which user did that -1. Never mind if it wasn't you. Just let me know if the new solution works
and maybe put a +1 on the new solution if it works :)
 
7:33 PM
I will, and hopefully it does! I plan on it, and giving you a +1 anyways for taking the time to help :)
 
very apreciate
I really hope that would fix your issue
 
Question, if I have two <script src>s at the end will it bother the script you wrote up for the bottom?
 
no, you can have as many <script> as you want, but you can just merge them together
 
Okay thanks!
 
7:49 PM
are you still there?
does it work?
 
Still here, nope I have a Server error (500) trying to make sure I don't have something stupid missing like semi colon or something
*on my end
 
error 500 is a server error
maybe the information we're sending to the server side are not formatted in the correct way
 
Yes but my server is fine... I get it when my code doesn't match up right...
 
that's why I asked you before what information the server needs
 
Hmmm... I see what you are saying
I was not a part of this design and the other people that I am working with aren't very straight forward about what I need. The information with the curls I sent you before is what they told me I needed, and all the information I should need
 
8:00 PM
can I try to use your server for sending a request from my code?
 
It won't work, this information I am accessing can only be accessed via LAN. makes my testing environment a pain in my ass
 
 
1 hour later…
9:12 PM
Tried this same code a few different ways so I can figure out what it is my server needs and haven't figured it out yet. I'm leaving for the weekend and will update in my question if/when I solve it
 

last day (15 days later) »