Hello,
First a little background on my issue. I have two multi select boxes. The first select box (box1[]) is populated from a table. The second select box (box2[]) will be populated by "clicking over" options from box1. These options are rights to be assigned to a specific person.

The issue that I'm having is with saving off these values into a table. My form has action='a javascript file' which I am using AJAX to populate some additional fields on the form.

My thought is that since I've created these multiple select boxes as arrays, I could pass the array from the PHP (through the javascript) and eventually end up in another PHP file that does the querying of the database (in this case, an INSERT into a table). But that's where I think I'm making this too difficult. From what I've read, it's possible to pass a PHP array to another PHP file (using either hidden fields or the encode/decode and serialize/unserialize functions; however I'm not sure how to incorporate the javascript file sitting between my two PHP files.

Here is my javascript that is getting the values from my original PHP file, and then submitting them to a second PHP file (with the params in the URL). I'd like to be able to pass the values of Box2 in a similar fashion (somehow)...

function insertuser() {
var sup = encodeURI(document.getElementById('sup').value);
var rpt = encodeURI(document.getElementById('rpt').value);
var bud = encodeURI(document.getElementById('bud').value);
var netid = encodeURI(document.getElementById('netid').value);

nocache = Math.random();
http.open('get', 'cbrs_insertuser.php?net_id='+netid+'&sup='+sup+'&rpt='+rpt+'&bud='+bud+'&nocache='+nocache);

Thanks so much in advance for any help you could provide.

Will Gresham commented: Good job on code tags and legible text :) +2

Recommended Answers

All 2 Replies

Member Avatar for diafol

Why don't you pass the info via POST instead of GET?

Else, you could json encode array values in js and decode them in your 'waiting' php file.

Have a look at prototype or jQuery libraries - takes the sting out of ajax.

Why don't you pass the info via POST instead of GET?

Else, you could json encode array values in js and decode them in your 'waiting' php file.

Have a look at prototype or jQuery libraries - takes the sting out of ajax.

Yes, I changed my methodology to use POST and that worked perfectly for what I needed. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.