Then later on if you need to modify the form you will need to first delete from the db all the systems that are checked before you run the loop above.
Main Topics
Browse All TopicsHi All,
I'm having a few issues modifying a booking app.
I'm now working on a form to book multiple resources, the form part is ok but I cant seem to get the right way of processing the check boxes properly.
The user selects a platform type (eg SUN and or DISK) which executes the getsystems.php script to display all the available systems. The user then selects whatever systems are free for use. I then need to process all the checked boxes from the form then update the database using the form options and for each system selected in the reference array (at least thats what I think I need to do...)
Also, assuming the database update is successful I'd then like the form to be closed, it is previously opened with windowopen().
If the database update is not successful then I'd like to display an error message and return to the form.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks but I'm not sure thats it....
The systems, SUN, HP, INTEL etc are processed by the getsystems.php from ajax, this script will list all the available systems like; SUN01, SUN02, INTEL01, INTEL02 etc
Each system checkbox is built using the code from getsystems.php and displayed in the main form. Note that systemref will be the names like SUN01, SUN02 etc etc.
echo "<div class='reference'><input type='checkbox' name='reference[]' id='reference[]' /><a onmouseover=\"Tip('" . $systemtip . "',TITLE,'SYSTEM INFORMATION',TITLEALIGN,'c
Sorry, I was hoping I could have explained it better....
I can't seem to process the checkboxes named reference[] built using the getsystems.php script and generate the sql code to insert into the database.
By way of an example, assuming that there are no intel servers currently used and that the INTEL checkbox was selected, the getsystems.php script would return 87 Intel Servers available to be booked. If all these servers, INTEL01 thru INTEL87, are then checked by the user and then the user clicked on Add Booking, I would need the form to be processed and the records added into the database like this;
insert into test_dates values('INTEL01','2009-04-
insert into test_dates values('INTEL02','2009-04-
etc etc...
This is where the other options are taken from the form and repeated for every `insert` command for the database.
It's possible to to create an insert statement where all the values are listed and inserted as one sql statement but I also dont know how to build the insert string in this format either.... this may be a better way of doing this as I then only have to connect and insert to the database once.
eg/
insert into test_dates values('INTEL01','2009-04-
does this make sense??!
I'm really stuck with this, I've attached a screen pic of what happens when I select "SUN" from the Additional Systems box and I have selected a number of systems which are currently not booked out.
I have added an alert box to print_r the $_post['reference'] information but it just comes up bank.
The code to print the alert box is included below, it looks OK to me but I'm still relatively new.
One thing I did notice what that if I look at the source code I don't see the check boxes which were generated by the ajax code and getsystems.php.
I've been trying to do a bit of research. I believe some of my problem is ajax not doing a postback of the checkbox options....
This is starting to look like 2 questions, one for getting the postback working and the other for processing the postback data and generating the sql to update the database.
If anyone can confirm my thoughts I'll gladly split the question and ask a related Q for postback.
@jools: This is annoying but a fact: When a checkbox is not checked, there is NOTHING in the $_POST or $_GET array to indicate its status. It would have been so easy if the designers of the WWW had given us an indicator like "on" or "off" but that is not the case.
Run this script and experiment with it, and you can see what is afoot.
> When a checkbox is not checked, there is NOTHING in the $_POST or $_GET array to indicate its status.
I get that, I really do. however, when I click on SUN in the Additional Systems box it executes the getsystems.php script and then populates the SUN fieldset with the available SUN systems, when I select a number of SUN systems then select the "Add Booking" button at the bottom of the screen, it does not seem to return any values for the reference[] array.
What I cant get my head round is why after I've checked the SUN-01 ... boxes and clicked on add there seems to be nothing there. It's like the ajax stuff isnt building the page properly and passing the check boxes as part of the form.
I have to admit, I'm really stuck with this at the moment.
I can probably set up a demo on a friendly web site if it helps....
I've copied the form to a web server here; http://www.nutworks.co.uk/
If you select one of the servers it should list the hardware available, from that you just select what kit you want booked out then click on the Add button at the bottom it's supposed to add all the resources with the other form data to the database.
any thoughts as to what is (not) happening??
Hi, jools: It would be helpful to add error_reporting(E_ALL) to the action script (the "action script" is the one that processes the data from the "form script") and to look closely at the field called "reference" - it looks like the script has a foreach loop near line 36 that looks at $_POST['reference'] but there is no field in the form named 'reference' - so something may be confused there.
Also I could not find any code that updates a data base. Can you post that part?
Thanks, ~Ray
Hi Ray,
Thanks for having a quick look.
The reference field is added by the javascript/ajax stuff when it executes the getsystems.php script. I've attached the java code so you should be able to see this.
So, in summary, addm.php displays the main form you looked at, clicking on SUN/HP etc executes the getsystems.php which extracts the available systems from the database and adds this information to this form using the javascript/ajax stuff in allocate.js.
I've not written the update database part yet, that is what I am stuck on, I need to be able to process the form before I can do that.
Where exactly would I add the error_reporting to? Is it needed in addm.php or getsystems.php or both?
Whenever I am developing or debugging, I would put error_reporting(E_ALL) into every script. At this point in the application life cycle, you WANT to see the errors.
I think I would also approach this application design a little bit differently. I do not see a requirement for AJAX. Instead you can send ALL the data to the page and use onClick() to tell the DOM to reveal or hide the appropriate parts. That way, you will have everything in the form, even if it is not displayed on the browser window. And with everything in the form, you will have a fairly straightforward UPDATE statement, and substantially less risk of an "out-of-sync" data base.
I don't know - that's an application design question and I'm not really sure how your application works.
I was thinking that the AJAX call was needed to get information that could have been known before the page was loaded. My general strategy would be to send all of the HTML information if possible. (Things that make it not possible include security or giant data sets or unpredictable factors). So if the date is one of those unpredictable factors, then you're forced to use AJAX or use two separate pages.
Have you tried to visualize the data with the email-from-background-scri
Thanks for your assistance Ray, it's much appreciated...
I needed to get round having loads of forms so was told I needed to learn ajax.
You've seen the main form, you just enter the criteria then when you select the additional platform the ajax stuff uses the date ranges to find what systems are free and displays this in the checkboxes which the user can then select as they wish.
What I cant get the form to do is to process is this new data, (the check boxes which have the specific systems listed) and return the values for the checkboxes that have been selected once the user clicks on add booking.
I didnt think it was going to be this difficult to process a form!
I have added the email stuff to the getsystems.php script but it returns exactly what I expect it to, the system and the date ranges.... (see below).
I have noticed that if you look at the page source once the form has listed the systems, you don't see the checkboxes for the systems, just the ajax divs!
I've googled and checked literally hundreds of pages and online books but I cant find a way of getting ajax to generate checkboxes then process the new checkbox values. I have to admit, my ajax/php and java skills are somewhat limited.
I still don't know if ajax is capable of doing what I want or if I need to go back to the multiple form approach which will be easier to code but wont be what the user wants from the interface.
Are there any options for ajax I am missing??
"Are there any options for ajax I am missing??" -- That has got to be the world's most open-ended question ever! ;-)
At its heart, AJAX is just a way of sending data to a backend script and retrieving the stuff that comes back from the script. That can be a DIV or something much more interesting. Depending on the handshake between the browser script and the backend script, it can be really elaborate.
I have to leave this for a while, but let me give you a comment on checkboxes that might be useful. If the checkboxes in a form are NOT CHECKED, they are not present in $_POST, ie, the key that you would expect would have the name of the checkbox is simply not there (!). This is different from a text input field, which will be present and empty.
I'll look around and see if I can come up with some examples of how to make this work. It may take a while, but I'll get something back to you here.
Best, ~Ray
:-)
>> Depending on the handshake between the browser script and the backend script, it can be really elaborate.
Thats what is worrying me, I dont think my handshake is elaborate enough...
>> If the checkboxes in a form are NOT CHECKED, they are not present in $_POST
Yup, totally understand that! In my case however they are checked, I just cant seem to see the array I assign the values to.
>> I'll look around and see if I can come up with some examples of how to make this work.
...that would be truly marvellous....
While your hunting around, I was wondering... have I explained the way I want the form to work properly? I don't want you spending your time hunting around and it's not quite what I had in mind...
I'll keep hunting as well, I cant give up just yet...
Now the foreground script. It handles checkboxes and text input. If you run it with the background script you will see that the "checked" attribute comes through as true or false.
Not that I have anything against AJAX, but there are a lot of moving parts. I guess that's why many of my colleagues like jQuery!
http://en.wikipedia.org/wi
Best regards, ~Ray
With all the excitement the power supply on the server has popped it's cloggs and gone to the big used hardware store in the sky.... at least I hope it's the power supply and not the motherboard/cpu :-| in anycase, it's not working....
This will obviously delay things a little until I can get it back up and running again. Nw I have to find my special hammer.
Ray_Paseur,
can you help me, by indicating which comments you would accept, using the format:
http://#a<commentid>
thanks,
a3
I think the most generalized answer is the most useful for this Q
Like this?
http://#a<24291055>
Bset regards, ~Ray
Business Accounts
Answer for Membership
by: mstrelanPosted on 2009-04-28 at 15:20:51ID: 24255727
Hi,
In you html form you need to make a bunch of checkboxes with the name "systems[]" and ids like "systems_as400" and values like "as400".
eg..
Select allOpen in new window