Nottingham
asked on
How to use this SelectBox Javascript??
I have this script that passes values from one selectbox to another.
I need to add the values that are selected to a database.
The script works brilliantly in the browser.
But when I post the values of the form to a php script the values aren't there - I know this is something simple - but what??
Please see the script at http://www.european-machining.com/jscript.htm
I need to add the values that are selected to a database.
The script works brilliantly in the browser.
But when I post the values of the form to a php script the values aren't there - I know this is something simple - but what??
Please see the script at http://www.european-machining.com/jscript.htm
Extremely sorry for mixing vb with javaScript. Please modify the for loop to look as follows:
for(intIndex = 0; intIndex++; intIndex < intCount)
for(intIndex = 0; intIndex++; intIndex < intCount)
JavaScript loop should be
for(intIndex=0; intIndex<intCount; intIndex++)
If Nitin's suggestion doesn't work, then you might want to consider a messier way to to this. As each item is added or removed, you add it to a string stored in a hidden field. When you post the form, the contents of the hidden field will be posted. You can then use the split function to separate the elements so that you can manipulate them as necessary.
for(intIndex=0; intIndex<intCount; intIndex++)
If Nitin's suggestion doesn't work, then you might want to consider a messier way to to this. As each item is added or removed, you add it to a string stored in a hidden field. When you post the form, the contents of the hidden field will be posted. You can then use the split function to separate the elements so that you can manipulate them as necessary.
Thanks "fritz_the_blank", for refreshing my memory. You don't work in particular language in for couple of months and it starts getting rusty.
One problem, i am not getting mails from this site, have an idea, what to do?
One problem, i am not getting mails from this site, have an idea, what to do?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No mails here either. I will see if anyone has posted a message to community support.
Fritz the Blank
Fritz the Blank
Nottingham,
Have any of these comments helped you? If so, please accept one of them as an answer.
Thank you,
Fritz the Blank
Have any of these comments helped you? If so, please accept one of them as an answer.
Thank you,
Fritz the Blank
ASKER
Thanks for the added php info
01. In my opinion, the values which are selected are only sent in HTTP posting. So, you will need to manually selected all items in "To" list-box. This can be done with the help of a function as follows:
<Script Language="javaScript">
<!--
function selectAll()
{
var intCount = document.form.list2.length
var intIndex = 0;
for(intIndex = 0 to intCount-1)
{
document.form.list2.option
}
return true;
}
// -->
</Script>
02. Modify your html as follows as the above functions is called:
<input type="submit" onClick="javaScript:select
03. Please make values shorter as shown below, as they are sent as part of posting. You can always expand them again on server.
<OPTION VALUE="A">Adhesive</OPTION
<OPTION VALUE="B">Boxes</OPTION>
<OPTION VALUE="C">Cans</OPTION>
<OPTION VALUE="S">Strapping</OPTIO
<OPTION VALUE="M">Machines</OPTION
<OPTION VALUE="X">X-ray Machines</OPTION>
04. It is a good practise to name your html form even if it is not compulsory.
Unfortunately, i was not been able to test this on my local machine.