• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DYNAMIC LIST BOX

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on a shopping cart problem. My main page contains list of products. List box cotins number of items selected.
I want the total price of the items to be automati cally displayed when changes value in list box. I want guidance as how to proceed on this prolem.
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without writing the actual JavaScript, here's how:
The onchange event of the listbox will be your trigger. When that fires (user selected a new option), you grab the selectedIndex value, which will likely be the price, get the value from the textbox and add. That result then replaces the value in the textbox.
Have a try and let us know how it goes!
 
ZEESHAN AZIZ
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, Thanks for your message. In this problem I want to display the sum of the sellected index and the value in the text box, in the textbox.
For instance, if the sellected index is 4, the value displayed in the text box should be 4.
However I can not figure out how to update the values in the textbox. I will be much obliged for an early reply.

<div style="BACKGROUND-COLOR:YELLOW">
<form name ="myForm" target="_blank">
<P> SELECT NO OF TICKETS TO YOUR CHOSEN DESTINATION<p/>
<p> RYAN AIR FLT TO DUB:
<SELECT NAME ="aList" OnChange="ProcessIt(this.form, this.selectedIndex)">
<OPTION> 0.
<OPTION> 1.
<OPTION> 2.
<OPTION> 3.
<OPTION> 4.
<OPTION> 5.
<OPTION> 6.
</SELECT><p/>
Total Price of tickets $ <INPUT SIZE=12 TYPE="text" name="textBoxValue" value=0 </P>
<script language="javascript">
<!--
function ProcessIt(form,index){
form.textBoxValue.value= index;
}
//-->
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
reply
    Bookmark Topic Watch Topic
  • New Topic