473,498 Members | 310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

deleting items from droplist

TJS
if country other than us is selected, I want to show only wire transfer as
payment option.
can someone help me get this "deleteoptions" code to work ?

==========================================
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">

<script language="javascript">
function setPayment(obj) {
var indx = obj.options[obj.selectedIndex].value;
if (indx != "US") {
var obj2 = document.orderform.idPayment;
deleteOptions(obj2);
}
}

function deleteOptions(obj2) {
while (obj2.options.length>1) {
deleteIndex=obj2.options.length-1;
//alert(obj2.options[deleteIndex].value );
if (obj2.options[deleteIndex].value != "11") {
obj2.options[deleteIndex]=null;
}
}
}

</script>
<form METHOD="POST" name="orderform" ">
<TABLE BORDER="0" CELLPADDING="0" WIDTH="590" align="left">
<TD WIDTH="202"> Country </TD>
<TD WIDTH="393">
<SELECT name="countryCode" value="US" onChange="setPayment(this);" >
<OPTION VALUE="US" SELECTED >UNITED STATES( US)</OPTION>
<OPTION VALUE="AD" >ANDORRA( AD)</OPTION>
<OPTION VALUE="AE" >UNITED ARAB EMIRATES( AE)</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD colspan="2"><b>Payment </b></TD>
</TR>
<TR>
<TD width="202"> Pay with </TD>
<TD width="393">
<select name="idPayment" size="1">
<option value="5">Credit Card</option>
<option value="9">Check </option>
<option value="11">Wire Transfer</option>
</select>
</TD>
</TR>
</table>
</form>

Jul 23 '05 #1
3 1443


This might arguably be confusing, popping items in & out of a list box.
Users are more accustomed to disablement...

function setPayment(obj)
{
var v = obj.options[obj.selectedIndex].value,
bUS = (v == "US"),
bWire,
r = 0,
rad,
rads = obj.form.elements.idPayment;
while (rad = rads[r++])
{
bWire = (rad.value == '11');
rad.disabled = (!bUS && !bWire);
rad.checked = (!bUS && bWire);
}
}

onload = function()
{//keep things in sync
var el;
if (el = document.getElementById('countryCode'))
el.onchange();
}

<TD WIDTH="393">
<SELECT id="countryCode" name="countryCode" value="US"
onChange="setPayment(this)">
<OPTION VALUE="US" SELECTED="selected" >UNITED STATES(US)</OPTION>
<OPTION VALUE="AD" >ANDORRA(AD)[wire transfer only]</OPTION>
<OPTION VALUE="AE" >UNITED ARAB EMIRATES(AE)[wire transfer
only]</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD colspan="2"><b>Payment </b></TD>
</TR>
<TR>
<TD width="202"> Pay with </TD>
<TD width="393">
<label for="iP1"><input id="iP1" type="radio" name="idPayment"
value="5"> Credit card</label>
<label for="iP2"><input id="iP2" type="radio" name="idPayment"
value="9"> Check</label>
<label for="iP3"><input id="iP3" type="radio" name="idPayment"
value="11"> Wire transfer</label>
</TD>

Always back up at the server, of course.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #2
TJS wrote:
if country other than us is selected, I want to show only wire transfer as
payment option.
can someone help me get this "deleteoptions" code to work ?

[...]

As an alternative, why not make the payment methods into radio buttons?
Then users can only select one, and you can easily disable those you
don't want them to check.

If any country other than US is chosen, disable "Credit" and "Check"
and select "Wire transfer".
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Payment</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="javascript">
function setPayment(f,v) {
var ele = f.elements;
for (var i=0; i<ele.length; i++) {
if (ele[i].type == "radio") {
if(v != 'US') {
if (ele[i].value == "11" ) {
ele[i].checked = true;
} else {
ele[i].checked = false;
ele[i].disabled = true;
}
} else {
ele[i].disabled = false;
}
}
}
}
</script>
</head>
<body style="font-family: sans-serif;">
<form METHOD="POST" name="orderform" action="">
<table border="0">
<tr>
<td>Country</td>
<td>
<select name="countryCode" value="US" onChange="
setPayment(this.form,this.value);">
<option value="US" selected>United States (US)</option>
<option value="AD">Andorra (AD)</option>
<option value="AE">United Arab Emirates (AE)</option>
</select></label>
</td>
</tr><tr>
<td colspan="2" style="border-bottom: 1px solid blue;
padding: 5 0 0 0;"><b>Payment Method</b></td>
</tr><tr>
<td valign="top" style="padding: 3 0 0 0;">Pay with</td>
<td>
<input type="radio" name="payMethod" value="5"
checked="checked">Credit Card<br>
<input type="radio" name="payMethod" value="9">Check<br>
<input type="radio" name="payMethod" value="11">Wire Transfer<br>
<input type="reset" onclick="
setPayment(this.form,'US');this.blur();">
<td>
</tr>
</table>
</form>
</body>
</html>

Cheers.
--
Rob
Jul 23 '05 #3
TJS
good help, thanks all ..
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1461
by: Amit Kela | last post by:
I am using ASP with SQL for my database. The problem I have is that even after I have ordered certain items from the shopping cart table on the webpage, I cannot remove them - that is the entire...
2
1755
by: KraftDiner | last post by:
I have a list, and within it, objects are marked for deletion. However when I iterate through the list to remove objects not all the marked objects are deleted.. here is a code portion: i = 0...
1
7858
by: jez123456 | last post by:
Hi, I have a windows form with a listbox control. My code all works correctly when deleting an item from the listbox except the last item. I get the following message when trying to delete the...
4
1367
by: TJS | last post by:
After a post back the selected index should be rest in a droplist to match user's choice, but page always show selected item as first one in the droplist. How can iforce the selected item to be...
5
2124
by: TJS | last post by:
I need to add validation to drodownlist control but it sends back an error message that says: "System.Web.UI.WebControls.DropDownList' does not allow child controls" the code is : If...
0
1509
by: steven.shannon | last post by:
Hello, I'm writing an app that involves deleting all the items in a specified Outlook folder regardless of item type (i.e. Contacts, Tasks, etc.). This code was ported from VBA where it worked...
2
4864
by: Milsnips | last post by:
hi there, i have the following HTML code: -------------------------- <asp:DropDownList id="hddList" runat="server"> <asp:ListItem Value="1">Item 1</asp:ListItem> <asp:ListItem Value="2">Item...
0
1062
by: yuchang | last post by:
Hi, I try to use a droplist control to show a list value from Database table "A", and the droplist control is an item of a formview control, its data from Database table "B". My problem is how...
8
1937
by: Christian Bruckhoff | last post by:
Hi. I got a problem with deleting items of a vector. I did it like this: void THIS::bashDelPerson() { cout << "Bitte Suchstring eingeben: "; char search; cin >search;...
0
7124
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5460
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4586
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.