473,770 Members | 1,661 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 "deleteopti ons" code to work ?

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

<script language="javas cript">
function setPayment(obj) {
var indx = obj.options[obj.selectedInd ex].value;
if (indx != "US") {
var obj2 = document.orderf orm.idPayment;
deleteOptions(o bj2);
}
}

function deleteOptions(o bj2) {
while (obj2.options.l ength>1) {
deleteIndex=obj 2.options.lengt h-1;
//alert(obj2.opti ons[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="countryCo de" value="US" onChange="setPa yment(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">Credi t Card</option>
<option value="9">Check </option>
<option value="11">Wire Transfer</option>
</select>
</TD>
</TR>
</table>
</form>

Jul 23 '05 #1
3 1457


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.selectedInd ex].value,
bUS = (v == "US"),
bWire,
r = 0,
rad,
rads = obj.form.elemen ts.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.getEle mentById('count ryCode'))
el.onchange();
}

<TD WIDTH="393">
<SELECT id="countryCode " name="countryCo de" value="US"
onChange="setPa yment(this)">
<OPTION VALUE="US" SELECTED="selec ted" >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"><inpu t id="iP1" type="radio" name="idPayment "
value="5"> Credit card</label>
<label for="iP2"><inpu t id="iP2" type="radio" name="idPayment "
value="9"> Check</label>
<label for="iP3"><inpu t 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 "deleteopti ons" 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>Paymen t</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="javas cript">
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="countryCo de" value="US" onChange="
setPayment(this .form,this.valu e);">
<option value="US" selected>United States (US)</option>
<option value="AD">Ando rra (AD)</option>
<option value="AE">Unit ed Arab Emirates (AE)</option>
</select></label>
</td>
</tr><tr>
<td colspan="2" style="border-bottom: 1px solid blue;
padding: 5 0 0 0;"><b>Paymen t 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="checke d">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');thi s.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
1487
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 list shows up the next time the table is opened. is there any way I can delete the items once ordered so as to not let them show in my table??
2
1780
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 for obj in self.objList: if obj.mouseHit: print 'delete + ' + `i` self.objList.pop(i)
1
7902
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 last item:- Specified argument was out of the range of valid values. Parameter name: '64' is not a valid value for 'Value'. The 64 reduces depending on how many listbox items are displayed.
4
1383
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 reset I have: Sub Page_Load(s As Object, e As EventArgs) If Page.IsPostBack then
5
2141
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 e.ItemType = ItemType.FieldItem And e.ColumnName = "IDEvent" Then Dim ctlEvent As DropDownList = CType(e.Control, DropDownList) Dim compVal AS CompareValidator = New CompareValidator()
0
1538
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 okay, but now in .NET it is exceedingly too slow when attempting to delete large collections (roughly 10,000). It is on the order of 10 items deleted every 30 seconds. My function is as follows: Private Sub DeleteAllEntries()
2
4882
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 2</asp:ListItem> <asp:ListItem Value="3">Item 3</asp:ListItem> <asp:ListItem Value="4">Item 4</asp:ListItem> <asp:ListItem Value="5">Item 5</asp:ListItem>
0
1082
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 do I to DataBind the droplist control in Formview control EditItem mode? It means the droplist will show the default value from table B and replace the value after editing the formview by selecting a value from the droplist control.
8
1953
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; vector<Person>::iterator iter; iter = persons.begin();
0
9595
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10232
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10008
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8891
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.