Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add quantity

Status
Not open for further replies.

webgek

Programmer
Jun 10, 2005
11
NL
Hi
I have a script that passing multiple value to listbox
but that is based on one particular combobox..
besides this combobox values and want to add one textbox value next to this combobox value

for example so combobox value = "test"
textbox value "5"

in the listbox should appear "test 5"

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">


oldvalue = "";
function passText(passedvalue) {
if (passedvalue != "") {
var totalvalue = passedvalue+"\n"+oldvalue;
document.displayform.itemsbox.value = totalvalue;
oldvalue = document.displayform.itemsbox.value;

}
}

</script>

</HEAD>


<BODY>

<form name="selectform">
<font face="Arial, Helvetica, Sans Serif" size="3"><b>Select an Item:</b></font><br>
<select name="dropdownbox" size=1>
<option value="">Make selection</option>
<option value="Item 1">Item 1</option>
<option value="Item 2">Item 2</option>
<option value="Item 3">Item 3</option>
<option value="Item 4">Item 4</option>
<option value="Item 5">Item 5</option>
<option value="Item 6">Item 6</option>
</select>
<label>Quantity
<input type="text" name="psn" id="psn" />
</label>
<input type=button value="Add to list" onClick="passText(this.form.dropdownbox.options[this.form.dropdownbox.selectedIndex].value);">
</form>

<form name="displayform" >
<font face="Arial, Helvetica, Sans Serif" size="3"><b>Items added to list:</b></font><br>
<textarea cols="40" rows="5" name="itemsbox" ></textarea>
</form>
</body>
</html>

Please advise
 
Code:
function passText(passedvalue)
{
   if (passedvalue != '') {
   var box_empty = document.displayform.itemsbox.value=='';
   document.displayform.itemsbox.value += (box_empty?'':'\n')+passedvalue;
   }
}

- Lowet

[gray]Why can't all browsers parse pages the same way? It should be the Web designer who decides how to display the content, not the browser![/gray]
 
Hi
<input type="text" name="psn" id="psn" />
as you can see there is a inputbox
when filling in this box
and cick on add list...no any value is added to the textarea box...

Please advise...
Kisoen
 
Oh, sorry :p didn't see that input :p

Code:
var co = 0;

function passText(passedvalue)
{
   if (passedvalue != '') {
   var box_empty = document.displayform.itemsbox.value=='';
   document.displayform.itemsbox.value += (box_empty?'':'\n')+passedvalue;
   co++;
   document.selectform.psm.value = co;
   }
}

This would help.. :p

- Lowet

[gray]Why can't all browsers parse pages the same way? It should be the Web designer who decides how to display the content, not the browser![/gray]
 
it is my mistake

the <option value="">Make selection</option>
<option value="apple">apple</option>
<option value="banana">banana</option>
<option value="fruits">fruits</option>
</select>

this should be clear now
so just select an item and the psn input box is the quantity
if I select apple and fill in the psn input box 8
in the text area should come apple 8

NOT BREAK UP THE SELECTED ITEMS
I hope it is now clear for you...
Please advise
kisoen

 
Hehe, I understand.

Code:
function passText(passedvalue)
{
   if (passedvalue != '') {
   var box_empty = document.displayform.itemsbox.value=='';
   document.displayform.itemsbox.value += (box_empty?'':'\n')+passedvalue;
   document.displayform.itemsbox.value += ' '+document.selectform.psm.value;
   document.selectform.psm.value = 0;  [green]/*  If you want to reset the count input  */[/green]
   }
}


- Lowet

[gray]Why can't all browsers parse pages the same way? It should be the Web designer who decides how to display the content, not the browser![/gray]
 
greate it works perfectly..thx
can the quantity be displayed first?
so quantity and than a space and than the selected item..

Please advise
Kisoen
 
Sure and I'll make it clearer..

Code:
function passText(passedvalue)
{
   if (passedvalue != '') {
   var obj,am,item;
   obj = document.displayform.itemsbox;  //  The textarea
   am = document.selectform.psm.value;  //  The amount
   text_area.value += am+' '+passedvalue+'\n';
   document.selectform.psm.value = 0;  //  If you want to reset the count input
   }
}


- Lowet

[gray]Why can't all browsers parse pages the same way? It should be the Web designer who decides how to display the content, not the browser![/gray]
 
yes thanks
works perfectly...you are good man
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top