Jump to content

Recommended Posts

this is a script i did using php,html and js. the php works to select the data into the 1st column and theres a button to move selected data from col1 to col 2 where i want to submit it to a database.

 

the problem im having (as far as im aware anyway) is this line.

 

<option selected="selected"></option>

the data that is moved from col1 to col2 will not pass to the insert page (tested using get).

but if i use

<option selected="selected"></option>
<option>test data</option>

 

the "test data" is passed to the next page.

the question is how do i get the data that is passed to col2 using JS to be passed to the insert script ??

 


<p> </p>
<div align="center">
<form id="form2" name="form2" method="get" action="new.php">
<TABLE align="center">
<tr>
 <td>col 1</td>
 <td></td>
<td>col 2</td></tr>
<TR>
 <TD> <select size="5" name="lstBox" id="lstBox">


 <option value="II - ICruiser Mk. I">ICruiser Mk. I</option>
		 <option value="II - ICruiser Mk. ">ICruiser Mk. </option>
		 <option value="II - ICruiser Mk. ">ICruiser Mk. </option>
		 <option value="II - Cruiser Mk. I "> Cruiser Mk. I </option>
		 <option value="IV - IV- Covenanter ">IV- Covenanter </option>
		 <option value="IV - IV- Valentine ">IV- Valentine </option>
		 <option value="V - Crusader ">Crusader </option>
	 </select>

</TD>
<TD>
<input name="add" type="button" value="Add" onclick="FirstListBox();" />
<input name="remove" type="button" value="Remove" onclick="SecondListBox();"/>
</TD>
<TD>
<select name="ListBox1" size="5" multiple="multiple" id="ListBox1">
<option selected="selected"></option>
</select>
</TD>
<TR>
 <TD> </TD>
 <TD><input type="submit" id="submit2" value="Update" /></TD>
 <TD> </TD></tr>
</TABLE>
</form>
<SCRIPT type="text/javascript">
<!--
function SecListBox(ListBox,text,value)
{
try
{
var option=document.createElement("OPTION");
option.value=value;
option.text=text;
ListBox.options.add(option)
}
catch(er)
{
alert(er)
}
}
function OutPut(){
 for (var s=document.getElementById("ListBox1"),txt='',z0=0;z0<s.length;z0++){
 txt+=s.options[z0].value+':';
 }
 document.getElementById('ip').value=txt;
}
function FirstListBox(){
 var count=document.getElementById("lstBox").options.length;
for(var i=0;i<count;i++){
if(document.getElementById("lstBox").options[i].selected){
SecListBox(document.getElementById("ListBox1"),document.getElementById("lstBox").options[i].value,document.getElementById("lstBox").options[i].value);document.getElementById("lstBox").remove(i);
 break
 }
}
 OutPut();
}
function SortAllItems(){
var arr=new Array();
for(i=0;i<document.getElementById("lstBox").options.length;i++) {
arr[i]=document.getElementById("lstBox").options[i].value}arr.sort();
RemoveAll();
for(var i=0;i<arr.length;i++){
SecListBox(document.getElementById("lstBox"),arr[i],arr[i])}}function RemoveAll(){try{document.getElementById("lstBox").options.length=0
 }
catch(er){
 alert(er)
 }
}
function SecondListBox(){
 var count=document.getElementById("ListBox1").options.length;
for(var i=0;i<count;i++){
if(document.getElementById("ListBox1").options[i].selected){SecListBox(document.getElementById("lstBox"),document.getElementById("ListBox1").options[i].value,document.getElementById("ListBox1").options[i].value);document.getElementById("ListBox1").remove(i);
 break
}
 }
SortAllItems()
 OutPut();
}
//-->
</SCRIPT>

</body>
</html>

Edited by hyster
Link to comment
https://forums.phpfreaks.com/topic/273298-java-in-a-form/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.