If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > getting the price from a selected name into a text box...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-15-04, 11:46
pavaus pavaus is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
Unhappy getting the price from a selected name into a text box...

I currently have all my names going into a selectbox..but i also want the price of the name selected to go into a text box...
can anyone help me out with the code...

This is what i have so far.....

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("dbTest.mdb"))

set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT Name FROM Cpu", conn
%>



<TABLE BORDER=0 FONT SIZE="2">
<TR>
<TD ALIGN=RIGHT><H5>Combo1:
</TD>
<TD> <SELECT name=selection>
<OPTION value=selectzero selected>None
<% do until rs.EOF
for each x in rs.Fields
Response.Write("<OPTION value=")
Response.Write(x.value)
Response.Write(">")
Response.Write(x.value)
next
rs.MoveNext
loop
Response.Write("</OPTION></SELECT>")

rs.close
conn.close
%>
</TD>
<TD>
$<input type="text" name="amount" value="0" SIZE=4 readonly="readonly">
</TD>
</TR>
Reply With Quote
  #2 (permalink)  
Old 02-15-04, 17:25
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Do you want the value in the text box to change dynamically or do you want to submit the form back to get the value?

If you want it dynamically you will need to write some client side script, either vbscript or JavaScript.

If you want to submit back, then you need to determine what value was selected, get the price for that value and response.write it back to the input box.
Reply With Quote
  #3 (permalink)  
Old 02-16-04, 03:58
pavaus pavaus is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
I want it to happen dynamically....

jsSetText() {
Textbox.text = selection.SelectedValue.ToString()
}

<TD> <SELECT name=selection OnChange:"jsSetText()">
<OPTION value=selectedzero selected>None
<% do until rs.EOF
for each x in rs.Fields

i'm sure it looks something like this but i'm a little confused how it will get the price from the corresponding name with out a sql statement...and if that is needed where do i set that...
Reply With Quote
  #4 (permalink)  
Old 02-16-04, 08:11
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
Here is something from my Invoice Detail page on my Web database at www.bullschmidt.com/login.asp.

It calls a few of my library functions but hopefully even without thoses specific details this might give you some JavaScript ideas about it.

<script type="text/javascript"> <!--
function jsRecalcPg() {
// Dim var.
var frm;
var strInvDetailProdDescr;
var varInvDetailProdPrice;
var varInvDetailQty;
var varInvDetailTotal;

// Form.
frm = document.frmMain;

// InvDetailProdDescr.
// Retrieve from combo.
strInvDetailProdDescr = frm.InvDetailProdID.options[frm.InvDetailProdID.selectedIndex].text;
// Truncate to just the desired col.
strInvDetailProdDescr = strInvDetailProdDescr.substring(21, 41);
// Trim.
strInvDetailProdDescr = jpsjsTrim(strInvDetailProdDescr);
// Set form fld.
frm.InvDetailProdDescr.value = strInvDetailProdDescr;

// InvDetailProdPrice.
// Retrieve from combo.
varInvDetailProdPrice = frm.InvDetailProdID.options[frm.InvDetailProdID.selectedIndex].text;
// Truncate to just the desired col.
varInvDetailProdPrice = varInvDetailProdPrice.substring(42, 52);
// Trim.
varInvDetailProdPrice = jpsjsTrim(varInvDetailProdPrice);
// Set form fld.
frm.InvDetailProdPrice.value = varInvDetailProdPrice;

// InvDetailTotal.
// Convert to nums.
varInvDetailProdPrice = jpsjsCNum(varInvDetailProdPrice);
varInvDetailQty = jpsjsCNum(frm.InvDetailQty.value);
// Multiply & round.
varInvDetailTotal = jpsjsRound(varInvDetailProdPrice * varInvDetailQty, 2);
// Format.
varInvDetailTotal = jpsjsFormat(varInvDetailTotal, "type:number;pattern:$,0.00;neg)");
// Set form fld.
frm.InvDetailTotal.value = varInvDetailTotal;
}
//-->
</script>
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On