473,626 Members | 3,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

omerbutt
638 Contributor
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 1732
stepterr
157 New Member
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 Contributor
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 Contributor
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
4189
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 code will insert a visual indicator (e.g. *) to convey that the field must be filled in. However, if the user has made a selection in the pulldown list and has left an INPUT field empty, when the form reappears after validation, the pulldown menu...
2
12337
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 ... without having to get this value via html, is there any way I can passed the checked value via html .. maybe with syntax like n4.checked.value or something.. Many thanks. <html>
1
2899
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 text boxes? What this script is suppose to do is change the value of a second drop down list based on the selection from the first. Then a value is chosen from the script generated drop down list in the
1
5919
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 if when the list/menu (attribute6) value is "Ja" then to make the TextField Pas Nr (attribute4) required. And if when the list/menu (attribute6) value is "Nee" to make the TextField Pas Nr (attribute4) not required.
3
2576
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. .. http://www.geocities.com/jweinberg1975/dropdown_on_text00.html .. In order to see the behavior you should "mouseover" the white-on-black text segment that says "omnis dolor repellend" .. the thing is that I don't want for the whole space in the paragraph to be empty. I just need for the little menu to...
1
18664
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 <= 30; $i++) : ?> <tr> <th><?= $i ?></th>
2
3095
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 optino in dropdown menu then that id name etc shuld come in the textbox without refreshing the page... plz any help....... <%@ page import="java.util.*" %> <%@ page language="java" %> <%@ page import="java.sql.*" %> <HTML> <head>
5
5470
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 the left-position of an Element. This JavaScript functions works in FF and IE7 but does not work in IE6, In IE6 it retrieves the wrong offsetLeft value. Having investigated the problem I noticed it had something to do with the margin-left and position...
0
8203
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
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...
0
8642
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8512
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
7203
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
6125
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
5576
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();...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.