473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

corresponding db value in the text input box for the value in selection menu

omerbutt
638 512MB
hi there i have a tbl in db which has following fields
table name:stock
id_no(primary key...autono)
part_name(text)
price(currency)

now i have an asp and htmlbased form in which i have made a selection menu and an input field right under it
what i want is that my drop dow selection menu should have the total no of parts that are placed in the database and as soon as the user selects any of the parts,in the very next input field the same price saved in the db for that part should appear what i have done till now is as following i have made the selecion menu containing the db values of the field part_name and its working perfectly fine now what i want is that if i select name of any part no its corresponding price should appear in the text input box named "price" what should i be doing can any body help
Expand|Select|Wrap|Line Numbers
  1. <%
  2. set r=Server.CreateObject("ADODB.Recordset")
  3. connstr="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db/db1.mdb")
  4. strSQL="Select * from sotck;"
  5. r.open strSQL, connstr, 3
  6. %>
  7.     <td class="add"><div align="left">Customer Name:</div></td>
  8.     <td width="150" align="Center" valign="Center"><div align="left">
  9.     <SELECT name="cust_name" style="width:194px; height:17px; font-size:11px; font-family:tahoma; border-style:solid; border-width:1px; border-color:#4C4A48; color:#8C8B89; background-color:#0A0501 ">
  10.         <option value="none" selected="selected">Please select a Customer</option>
  11.         <%while not r.EOF%>
  12.         <option value="<%=r.Fields("part_name")%>"><%Response.Write(r.Fields("part_name"))%></option>
  13.     <%r.Movenext            
  14.     wend%>
  15.     </SELECT>
  16.     </div></td>
  17.     <td class="add" ><div align="left">Price:</div></td>
  18.     <td width="150" align="Center" valign="Center"><div align="left"><input name="price" type="text" size="25" style="width:194px; height:17px; font-size:11px; font-family:tahoma; border-style:solid; border-width:1px; border-color:#4C4A48; color:#8C8B89; background-color:#0A0501 "></div></td>
  19.  
Nov 29 '07 #1
3 1721
stepterr
157 100+
Try using the onchange event in your drop down list so that when they make the selection for the part you can call another function that will query your database for the price where the part is equal to the selection that they made. Then you can just display that result in your textbox
Nov 30 '07 #2
omerbutt
638 512MB
nice try to get started
its not all that simple i know i have to call an onchange method to cal js funtion which would get the current value of the part ..but..there are aloots of things that i had to manage i had already done alot work on it but its kind of mess ya know
i got the code lets see if you can help more than i know
Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. <title>Untitled Document</title>
  7. <script type="text/javascript">
  8. function price(pval)
  9. {
  10. Stamp = new Date();
  11. var xmlHttp
  12. var t
  13. try
  14. {
  15. // Firefox, Opera 8.0+, Safari
  16. xmlHttp=new XMLHttpRequest();
  17. }
  18. catch (e)
  19. {
  20. // Internet Explorer
  21. try
  22. {
  23. xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  24. }
  25. catch (e)
  26. {
  27. try
  28. {
  29. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  30. }
  31. catch (e)
  32. {
  33. alert("Your browser does not support AJAX!");
  34. return false;
  35. }
  36. }
  37. }
  38. xmlHttp.onreadystatechange=function() {
  39. if(xmlHttp.readyState==4) {
  40. document.getElementById("cust").value=xmlHttp.responseText
  41. }
  42. }
  43. xmlHttp.open("GET","test2.asp?cred_lim="+pval+"time=" + Stamp,true);
  44. xmlHttp.send(null);
  45. }
  46. </script>
  47. </head>
  48.  
  49. <body>
  50. <%
  51. set r=Server.CreateObject("ADODB.Recordset")
  52. connstr="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db/db1.mdb")
  53. strSQL="Select * from Cust;"
  54. r.open strSQL, connstr, 3
  55. %>
  56. <td class="add"><div align="left">Customer Name:</div></td>
  57. <td width="150" align="Center" valign="Center"><div align="left">
  58. <SELECT name="cust_name">
  59. <option value="none" selected="selected">Please select a Customer</option>
  60. <%while not r.EOF
  61. Dim nik=r.Fields("Cust_name")%>
  62. <option value="<%=r.Fields("Cust_name")%>" onclick="price('nik');"><%Response.Write(r.Fields("Cust_name"))%></option>
  63. <%r.Movenext
  64. wend%>
  65. </SELECT>
  66. </div></td>
  67. <td class="add" ><div align="left">Cred limit:</div></td>
  68. <td width="150" align="Center" valign="Center"><div align="left"><input name="cred_lim" type="text" size="25" id="prc"></div></td> 
  69. </body>
  70. </html>
  71.  
Try using the onchange event in your drop down list so that when they make the selection for the part you can call another function that will query your database for the price where the part is equal to the selection that they made. Then you can just display that result in your textbox
Dec 1 '07 #3
omerbutt
638 512MB
gud try to get started :D
well i got the solution for it i got to use AJAX ;) buddy cause other wise i will not be able to do that javascript does not support writing SQL queries that much and thats y uses forms and button to submit the data and communicate with the server and a new page will load showing the results for the selected serch or records added where as AJAX uses http response objects which don let u redirect or load another page and show the queried values or result on the same page without re-loading [;)]
Try using the onchange event in your drop down list so that when they make the selection for the part you can call another function that will query your database for the price where the part is equal to the selection that they made. Then you can just display that result in your textbox
Dec 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mark R | last post by:
I have one .asp page with a SELECT pulldown list on it and some INPUT fields. When SUBMIT is clicked the form data is submitted to that same page and validated. If INPUT fields are empty the asp...
2
by: jason | last post by:
The following (likely far from imperfect code), reports a value of NaN in the j4 display. I suppose the problem is I am not really passing the "checked" value of the radio button via .value ......
1
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the...
1
by: platostoteles | last post by:
Hallo NG, I am new to JavaScript and would really appreciate any help to solve my problem. I am using the blow code in my form to validate form fields. What I would like to accomplish is that...
3
by: jweinberg1975 | last post by:
I would like for users to be able to select from a small number of options that come from a little drop down menu which then closes. .....
1
by: sksksk | last post by:
I want to achieve the following process in the smarty for $item one i should be able to get the value using loop.index, but without any luck. any help is appreciated. <?php for ($i = 1; $i...
2
by: manishamca | last post by:
In dropdown i am retriving value from the backend. For eg: in the dropdown list the value selected are employee id..then i want to disply the emp name,job etc in the textbox. If i select a...
5
by: montybytes | last post by:
Hi there, Although, I have already placed this question in the HTML/CSS section, perhaps it might be worthwhile asking the question here as well. I have a JavaScript function which retrieves...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...

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.