Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Multiple GETs w. the same name

4:32 pm on May 11, 2005 (gmt 0)

New User

10+ Year Member

joined:Apr 8, 2004
votes: 0

The code I'm writing is using javascript and PHP.

Basically, it's a form that people add things to a drop down list w. javascript. The form is then submitted and all of the things in the drop down list (if selected) are submitted through GET (Which I will probably change later.)

I've done this before in PHP only where I could just assign an incrementer at the end of the "name" variable on each text field. However, I have multiple results going to the same "name" field now.

Here's an example of what shows when I do a print_r on $_REQUEST

mySelect = test

But my url looks like this

It grabs the last value, I understand that. Anyway to stop this behavior? Or am I just hoping for the impossible.

5:51 pm on May 11, 2005 (gmt 0)

New User

10+ Year Member

joined:Apr 8, 2004
votes: 0

Nevermind, I figured it out. For anyone else trying to do something similar, this is what I did ...


function addSelect(name,value)
var x=document.getElementById('mySelect[]')
x.options[x.options.length] = new Option(name, value);
x.size = x.length
function sizeChange()
var x=document.getElementById('mySelect[]')
var length=x.length


print "<html>";
print "<head>";print "<script src=\"script.js\"></script>";
print "</head>";
print "<body onload=\"sizeChange()\">";
print "<form name=\"form\" action=\"{$_SERVER{'PHP_SELF'}}\">";
print "Name : <input type=\"text\" name=\"name\"><br>";
print "Value : <input type=\"text\" name=\"value\"><br>";
print "<br>The select box:<br>";
print "<select id=\"mySelect[]\" name=\"mySelect[]\">";
print "<option>-- Add Things --</option>";
print "</select>";
print "<br><br>";
print "<input type=\"button\" onclick=\"addSelect(document.form.name.value,document.form.v
alue.value)\" value=\"Add values\"><BR>";
print "<input type=\"submit\" value=\"Test PHP Submit\" name=\"submit\" onclick=\"printVal
print "</form>";
print "</body>";
print "</html>";
print "<pre>";
print "</pre>";

PS. What's up with these forums. Can't have new lines in code tags? :(


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members