Move/Add/Swap/Transfer Data Client Side
If you’ve ever had two multiple selection boxes, and wanted to transfer the values of the multiple selection boxes back and forth, then finally submit the code in the adjusted multiple selection box(s), here’s the code to do it!
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Transfer Values Back & Forth</title>
<style type="text/css">
TABLE {
BORDER-BOTTOM: 0px;
BORDER-LEFT: 0px;
BORDER-RIGHT: 0px;
BORDER-TOP: 0px;
FONT-FAMILY: tahoma,sans-serif;
FONT-SIZE: 14px;
FONT-WEIGHT: BOLD;
COLOR: White;
}
.MSB {
BORDER-BOTTOM: 0px;
BORDER-LEFT: 0px;
BORDER-RIGHT: 0px;
BORDER-TOP: 0px;
FONT-FAMILY: tahoma,sans-serif;
FONT-SIZE: 12px;
}
.Main {
BORDER-BOTTOM: 0px;
BORDER-LEFT: 0px;
BORDER-RIGHT: 0px;
BORDER-TOP: 0px;
FONT-FAMILY: tahoma,sans-serif;
FONT-SIZE: 12px;
COLOR: White;
}
</style>
<script language="JavaScript">
<!--
var conAdd = 'Add';
var conRemove = 'Remove';
var delimiter = "|";
function MoveOption(f, From, To, action) {
var eFrom = eval('f.msb' + From);
var eTo = eval('f.msb' + To);
var selection = eFrom.options.selectedIndex;
var eAddContainer;
var eRemoveContainer;
if (action == conAdd) {
eAddContainer = eval('f.htx' + conAdd + To);
eRemoveContainer = eval('f.htx' + conRemove + To);
}
if (action == conRemove) {
eAddContainer = eval('f.htx' + conRemove + From);
eRemoveContainer = eval('f.htx' + conAdd + From);
}
if (selection == -1) {
alert("Please select one or more users to move.");
} else {
eval('f.cmd' + action + '.disabled = true;');
for (i = 0; i < eFrom.options.length; i++) {
if(eFrom.options[i].selected) {
var name = eFrom.options[i].text;
var ID = eFrom.options[i].value;
eFrom.options[i] = null;
eTo.options[eTo.options.length] = new Option (name,ID);
i = i - 1;
var rep = new String('\\' + delimiter + ID + '\\' + delimiter + '');
var repExp = new RegExp(rep);
if (eRemoveContainer.value.match(repExp) == null) {
eAddContainer.value = eAddContainer.value + ID + delimiter;
} else {
eRemoveContainer.value = eRemoveContainer.value.replace(repExp,delimiter);
}
}
}
}
}
function onChange_msbUserPool(f) {
f.cmdAdd.disabled = (f.msbUserPool.selectedIndex == -1);
}
function onChange_msbAssignedUser(f) {
f.cmdRemove.disabled = (f.msbAssignedUser.selectedIndex == -1);
}
-->
</script>
</head>
<body>
<form action="more_values.html" method="post" id="thisForm" name="thisForm">
<input type="hidden" name="htxAddAssignedUser" id="htxAddAssignedUser" value="|">
<input type="hidden" name="htxRemoveAssignedUser" id="htxRemoveAssignedUser" value="|">
<table width="600" border="1" bordercolor="#103052" cellspacing="0" cellpadding="0" align="center" bgcolor="#336699">
<tr>
<td>
<table border="0" bordercolor="red" cellspacing="0" cellpadding="3" align="center" width="100%">
<tr>
<td height="5" colspan="3"/>
</tr>
<tr class="main">
<td colspan="3">Click on a member or members of Team One and then click Assign, or click on a member of Team Two, and click remove to assign back to Team One.</td>
</tr>
<tr>
<td height="5" colspan="3"/>
</tr>
<tr>
<td valign="top" width="50%">
<table border="1" cellspacing="0" cellpadding="0" class="main" align="center" bordercolor="#103052">
<tr>
<td valign="middle" id="lblUserPool" bgcolor="#103052" nowrap> Team One: </td>
</tr>
<tr>
<td valign='top' align="center">
<select multiple size='20' id='msbUserPool' name='Unassigned User Pool' class='msb' onchange='onChange_msbUserPool(thisForm);'>
<option value="1">Smith, John</option>
<option value="2">Smith1, John</option>
<option value="3">Smith2, John</option>
<option value="4">Smith3, John</option>
<option value="5">Smith4, John</option>
<option value="6">Smith5, John</option>
</select>
</td>
</tr>
</table>
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0" class="main" align="center" bordercolor="red" width="100%">
<tr>
<td align="center"><input disabled onclick="MoveOption(thisForm,'UserPool','AssignedUser','Add');" type="button" value="Move >>" name="Assign User" id="cmdAdd" class="fbbutton"></td>
</tr>
<tr>
<td height="25"/>
</tr>
<tr>
<td align="center"><input disabled onclick="MoveOption(thisForm,'AssignedUser','UserPool','Remove');" type="button" value="<< Move" name="Remove User" id="cmdRemove" class="fbbutton"></td>
</tr>
</table>
</td>
<td valign="top" width="50%" align="center">
<table border="1" cellspacing="0" cellpadding="0" class="main" bordercolor="#103052">
<tr bgcolor="#103052">
<td valign="middle" id="lblAssignedUser" nowrap> Team Two: </td>
</tr>
<tr>
<td valign="middle" align="center">
<select multiple size="20" id="msbAssignedUser" name="Assigned Users" class="msb" onchange="onChange_msbAssignedUser(thisForm);">
<option value="1">Smith, Jane</option>
<option value="2">Smith1, Jane</option>
<option value="3">Smith2, Jane</option>
<option value="4">Smith3, Jane</option>
<option value="5">Smith4, Jane</option>
<option value="6">Smith5, Jane</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="15" colspan="3"/>
</tr>
<tr>
<td valign="top" align="center" colspan="3">
<table border="0" cellspacing="0" cellpadding="0" class="main">
<tr>
<td><input type="submit" value="Submit Updates" id="cmdSubmit" name="Submit Updates"></td>
<td width="15"></td>
<td><input type="button" value="Reset" id="cmdReset" name="Reset" onClick="location.reload(true);"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="15" colspan="3"/>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
#include<string.h>
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
class AbstractPizza{
protected:
unsigned int price;
int olives;
int mushrooms;
float flour;
int onion;
int cheese;
int tomatoes;
int chicken;
int beef;
public:
virtual void bake()=0;
virtual int returnprice()=0;
// virtual ~AbstractPizza();
};
class ChickenTikkaPizza : public AbstractPizza{
public:
ChickenTikkaPizza();
void bake();
int returnprice(){ return price;}
};
void ChickenTikkaPizza::ChickenTikkaPizza(){
price= 450;
olives=20;
mushrooms=20;
flour=2;
onion=5;
cheese=2;
tomatoes= 4;
chicken= 2;
beef=3;
}
void ChickenTikkaPizza::bake()
{
olives=10;
mushrooms=15;
flour=1;
onion=3;
cheese=1;
tomatoes= 2;
chicken= 1;
beef=3;
cout<<"\n\nYour Pizza is ready to be delivered, Thanks for coming, Please do come again";
}
class BeefRoastPizza : public AbstractPizza{
public:
BeefRoastPizza();
int returnprice(){ return price;}
void bake();
};
void BeefRoastPizza::BeefRoastPizza(){
price=415;
olives=20;
mushrooms=20;
flour=2;
onion=5;
cheese=2;
tomatoes= 4;
chicken= 2;
beef=3;
}
void BeefRoastPizza::bake()
{
olives=10;
mushrooms=15;
flour=1;
onion=3;
cheese=1;
tomatoes= 2;
chicken= 2;
beef=1;
cout<<"\n\nYour Pizza is ready to be delivered, Thanks for coming, Please do come again";
}
class FourSeasonPizza : public AbstractPizza{
public:
FourSeasonPizza();
int returnprice(){ return price;}
void bake();
};
void FourSeasonPizza::FourSeasonPizza(){
price= 475;
olives=20;
mushrooms=20;
flour=2;
onion=5;
cheese=2;
tomatoes= 4;
chicken= 2;
beef=3;
}
void FourSeasonPizza::bake()
{
olives=10;
mushrooms=15;
flour=1;
onion=3;
cheese=1;
tomatoes= 2;
chicken= 1;
beef=1;
cout<<"\n\nYour Pizza is ready to be delivered, Thanks for coming, Please do come again";
}
class HawiianPizza : public AbstractPizza{
public:
HawiianPizza();
int returnprice(){ return price;}
void bake();
};
void HawiianPizza::HawiianPizza(){
price=420;
olives=20;
mushrooms=20;
flour=2;
onion=5;
cheese=2;
tomatoes= 4;
chicken= 2;
beef=3;
}
void HawiianPizza::bake()
{
olives=10;
mushrooms=15;
flour=1;
onion=3;
cheese=1;
tomatoes= 2;
chicken= 1;
beef=1;
cout<<"\n\nYour Pizza is ready to be delivered, Thanks for coming, Please do come again";
}
class person{
private:
char Name[15];
char SirName[15];
char PoBox[15];
char HouseNum[15];
char StreetNum[15];
char Sector[15];
char City[15];
char PhoneNumber[15];
char Country[15];
public:
void input();
void display();
};
void person::input()
{ cout<<"\n\t **********Customer Information**********\n";
cout<<"\nPlease enter your first name:\t\t";
gets(Name);
cout<<"Please enter your surname:\t\t";
gets(SirName);
cout<<"Please enter Your P.O Box Number:\t";
gets(PoBox);
cout<<"Please enter your House Number:\t\t";
gets(HouseNum);
cout<<"Please enter your Street Number:\t";
gets(StreetNum);
cout<<"Please enter your Sector:\t\t";
gets(Sector);
cout<<"Please enter your Phone Number:\t\t";
gets(PhoneNumber);
}
void person::display()
{
cout<<"\n\nThank You for coming, "<< Name<<" "<<SirName<<" \n\nPlease enter 'n' to quit and any other character to \ncontinue ordering pizzas:";
}
class creditcard{
private:
unsigned int ExpiryMonth;
unsigned int ExpiryYear;
unsigned long MaxSize;
unsigned long CurrentSize;
unsigned long CreditCardNumber;
public:
creditcard();
creditcard(unsigned int month, unsigned int year, unsigned long ccnumber);
int compare(creditcard ca);
void input();
unsigned long ReturnCurrentSize(){ return CurrentSize; }
};
void creditcard::creditcard(){
MaxSize= 20000;
CurrentSize= rand() %20000;
}
int creditcard::compare(creditcard ca)
{
if(ExpiryMonth==ca.ExpiryMonth && ExpiryYear==ca.ExpiryYear && CreditCardNumber==ca.CreditCardNumber)
return(1);
else
return(0);
}
void creditcard::input()
{ cout<<"\n\t**********Enter Credit Card Information**********";
cout<<"\n\nPlease enter the Credit Card Number\t";
cin>>CreditCardNumber;
ExpiryMonth=0;
while(!(ExpiryMonth>=1 && ExpiryMonth<=12))
{
cout<<"Please enter that expiry month( between 1 and 12)\t";
fflush(stdin);
cin>>ExpiryMonth;
}
cout<<"Please enter the expiry year\t\t";
cin>>ExpiryYear;
}
void creditcard::creditcard(unsigned int month, unsigned int year, unsigned long ccnumber){
ExpiryMonth= month;
ExpiryYear= year;
CreditCardNumber=ccnumber;
}
class order{
private:
person p1;
creditcard c1;
static int OrderNumber;
public:
void incrementordernumber(){ OrderNumber++; }
int returnordernumber(){return OrderNumber; }
unsigned long returnc1size(){ return(c1.ReturnCurrentSize()); }
void c1input(){ c1.input(); }
int comparecredit(creditcard ca){return(c1.compare(ca));}
void inputperson(){ p1.input(); }
void displayperson(){ p1.display(); }
void menu();
};
int order::OrderNumber=0;
void order::menu(){
cout<<"\n\n\n\n\n\t\t***************MENU****************";
cout<<"\n\t\t*1) Chicken Tikka Pizza....Rs. 450*";
cout<<"\n\t\t*2) Beef Roast Pizza.......Rs. 415*";
cout<<"\n\t\t*3) Four Season............Rs. 475*";
cout<<"\n\t\t*4) Hawaiian Pizza.........Rs. 420*";
}
main()
{
clrscr();
char option;
AbstractPizza* ap1;
while( option != 'n' )
{
clrscr();
order o2;
o2.incrementordernumber();
o2.menu();
int choice;
cout<<"\n\t\t********ORDER NUMBER:\t"<<o2.returnordernumber()<<"**********\n";
choice=5;
while(!(choice>=1 && choice<=4))
{
cout<<"\nPlease Enter Your Choice between 1 & 4:\t\t";
cin>>choice;
}
switch(choice)
{
case(1):
ap1= new ChickenTikkaPizza;
break;
case(2):
ap1= new BeefRoastPizza;
break;
case(3):
ap1= new FourSeasonPizza;
break;
case(4):
ap1= new HawiianPizza;
break;
}
o2.inputperson();
char choice2='l';
do{
cout<<"\nPlease enter c to pay via credit card and p to pay via cash:\t";
fflush(stdin);
cin>>choice2;}
while(!(choice2=='c' || choice2=='p'));
if(choice2=='c')
{
o2.c1input();
creditcard cca(12, 2004, 1111222233334444);
creditcard ccb(12, 2004, 1234567890123456);
creditcard ccc(12, 2004, 9876543210987654);
creditcard ccd(12, 2004, 1212121212121212);
clrscr();
if( ( o2.comparecredit(cca) || o2.comparecredit(ccb) || o2.comparecredit(ccc) || o2.comparecredit(ccd) ) && ( o2.returnc1size() >= ap1->returnprice() ) )
{
cout<<"\n\n\n\n\n\n****Your Account Balance\t"<<o2.returnc1size()<<"\n****Your Order Cost \t\t"<<ap1->returnprice()<<"\n****Balance after transaction\t"<<o2.returnc1size()-ap1->returnprice() ;
ap1->bake();
}
else
{
if(!( o2.comparecredit(cca) || o2.comparecredit(ccb) || o2.comparecredit(ccc) || o2.comparecredit(ccd) ))
cout<<"\n\n\n\n\n\nINVALID CREDIT CARD NUMBER , ORDER COULD NOT BE PROCESSED";
else if(! ( o2.returnc1size() >= ap1->returnprice() ) )
cout<<"\n\n\n\n\n\nINSUFFICIENT FUNDS , ORDER COULD NOT BE PROCESSED";
}
}
else
cout<<"\nThanks for paying by CASH";
choice2='l';
o2.displayperson();
fflush(stdin);
option=getch();
}
delete ap1;
return 0;
}
Original Comments (3)
Recovered from Wayback Machine