expand <input type..
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
foo.html
foo.php
clicking submit with ps2 selected:
hitting enter with xbox selected:
Code: Select all
<html>
<script language="Javascript">
function getElem(id)
{
return document.getElementById?document.getElementById(id):document.allїid];
}
function updateForm(index)
{
var updArea = getElem('updArea');
switch(index)
{
case 1:
updArea.innerHTML = '<br>Game Name:<input type="text" name="ps2" size="10"></input>';
break;
case 2:
updArea.innerHTML = '<br>Game Name:<input type="text" name="xbox" size="10"></input>';
break;
case 3:
updArea.innerHTML = '<br>Game Name:<input type="text" name="pc" size="10"></input>';
break;
case 4:
updArea.innerHTML = '<br>Game Name:<input type="text" name="something" size="10"></input>';
break;
default:
updArea.innerHTML = 'Please Select';
break;
}
}
</script>
<body onload="document.formsї0].selectedIndex = 0;">
<form action="foo.php" method="post">
<select onchange="updateForm(this.selectedIndex)">
<option>-select-</option>
<option>ps2</option>
<option>xbox</option>
<option>pc</option>
<!-- whatever else... -->
</select><span id="updArea"></span><br>
<INPUT TYPE="submit" name="submit" value="submit"></form>
</body>
</html>Code: Select all
<?php
header('Content-type: text/plain');
print_r($_POST);
?>Code: Select all
Array
(
їps2] => feyd clicked submit
їsubmit] => submit
)Code: Select all
Array
(
їxbox] => feyd pressed enter
)if i see this correctly the thing changed is
I will try this.. thanks for the help
Code: Select all
onload="document.formsї0].selectedIndex = 0;"- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
that wasn't the real change.. that was a tweak to make it, on first load, say "Please Select"
the change that made it work:
originally you had(ignore the string changes, but the = sign is the important part.) Without the equal sign, there is nothing to pass, so posted data is empty.
the change that made it work:
Code: Select all
...name="ps2"...
...name="xbox"...
...name="pc"...
...name="something"...Code: Select all
...name"gname"...
...name"gname"...
...name"gname"...
...name"gname"...