Hi,
I'm having problems retrieving the information that is stored in a listbox. I'm using Javascript to populate the listbox. Now i want to use the information in that same listbox on the next php-page. I'm not sure if this is even possible, or that i'm just doing something wrong. I'm kinda new at PHP, so bear with me please. The follwing code is used to populate the listbox:
<script language="JavaScript">
<!--
function checkPresence(substance){
var i;
var result=0;
var substancearray;
var pattern=": ";
for(i=0;i<document.formtest.substancelist.length;i++)
{
substancearray=document.formtest.substancelist[i].text.split(pattern);
if(substance==substancearray[0])
result=1;
}
return result;
}
function updateItem() {
var index;
var itemtext=document.formtest.substancename.value;
itemtext+=": "+document.formtest.substancepercentage.value+"%";
if(checkPresence(document.formtest.substancename.value)==1)
alert("substance already present in list");
else
{
if(document.formtest.substancelist[0].text=="-Substance info-") index=0;
else index=document.formtest.substancelist.length;
document.formtest.substancelist[index]=new Option(itemtext, document.formtest.substancelist.length);
}
}//-->
</script>
<P>
<FORM NAME="formtest" ACTION="savecomposition.php" METHOD="POST">
<INPUT TYPE="TEXT" SIZE=15 NAME="substancename">
<INPUT TYPE="TEXT" SIZE=4 NAME="substancepercentage">%
<INPUT TYPE="BUTTON" onClick="updateItem()" VALUE="Add">
<SELECT NAME="substancelist" SIZE=5>
<OPTION>-Substance info-</OPTION>
</SELECT><BR>
<INPUT TYPE="SUBMIT" VALUE="Save">
</FORM>
</P>
Usually the name of the component (e.g. editbox) can be easily retrieved by using $REQUEST (or $POST). But when i used $_REQUEST["substancelist"] (see code above), i got the following error "PHP Warning: Undefined index:". I hope my problem is something familiair and can be resolved easily.
Many thnx,
Duderino