moving values from one list box to another listbox ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
callsreenu
Forum Newbie
Posts: 6
Joined: Sun Nov 23, 2008 11:03 pm

moving values from one list box to another listbox ?

Post by callsreenu »

<td style="width: 100px;"><label for="city1">City(s)</label>
<br />

<?php
$city1 = $_POST['CityId1'];
if($country)
echo $this->formSelect('CityId1', $city1, array('multiple'=>'true','style'=>'height: 100px; width: 100px;'), $this->getCitysinIndia());// here i will get all the cites those will be in first list box
else
echo $this->formSelect('CityId1', 'Hyderabad', array('multiple'=>'true','style'=>'height: 100px; width: 100px;'), $this->getCitysinIndia());
?>

</td>

<td style="width: 30px;">
<input style="width: 120px;" type="button" id="toright" name="toright" value=">>" onclick="moveoutid()" /><br />
<input style="width: 120px;" type="button" name="toleft" name="toleft" value= "<<" onclick="moveinid()" />
</td>

<td>
<label for="city2">Selected City(s)</label>
<select id="CityId2[]" name="CityId2[]" multiple="multiple" style="height: 100px; width: 100px;">
//when will click on >> button selected city of first list box data must display in the second list box
</select>
</td>

<input type="submit" id="save" name="save" value="Save" />


by using javascript when ever i press >> button i can take out the value from first list box and i can place inside second list box , iam doing same think for << button also

my javascript code is :

function moveoutid()
{
var selcity1 = document.getElementById('CityId1');;
var len = selcity1.length;
var selcity2 = document.getElementById('CityId2');
for(var j=0; j<len; j++)
{
if(selcity1[j].selected)
{
var tmp = selcity1.options[j].text;
var tmp1 = selcity1.options[j].value;
selcity1.remove(j);
j--;
var y=document.createElement('option');
y.text=tmp;
try
{selcity2.add(y,null);
}
catch(ex)
{
selcity2.add(y);
}
}
}
}


function moveinid()
{
var selcity1 = document.getElementById('CityId1');
var selcity2 = document.getElementById('CityId2');
var len = selcity2.length;
for(var j=0; j<len; j++)
{
if(selcity2[j].selected)
{
var tmp = selcity2.options[j].text;
var tmp1 = selcity2.options[j].value;
selcity2.remove(j);
j--;
var y=document.createElement('option');
y.text=tmp;
try
{
selcity1.add(y,null);}
catch(ex){
selcity1.add(y);
}

}
}
}
</script>


MY QUESTION IS :
when ever i press Save button it goes to the validation part in server side,
by using $advCity2 = $_POST['advCity2[]']; i want to take the all the second list box values and save inside the database . but all the values are not coming ? what shall i do?

any body please help me urgent....
Post Reply