|
|
Hi,
I have the following code to access an SQL table and 'dynamically' populate a listbox.
What I would like to do is add an onchnage event where the selected value is placed in a Textfield on the same page.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Drop Down Test</title>
</head>
<body>
<%
dim directorate
directorate = session("Directorate")
dim strSQL
set Conn=Server.CreateObject("ADODB.Connection")
DSN="Driver={SQL Server};Server=BROINFO;Database=ref_datadb;UID=sa; PWD=inforep"
Conn.Open(DSN)
strSQL = "SELECT Main_specialty_description as 'spec_code' FROM main_specialty_look_up where rtrim(directorate) = '" & directorate & "' order by main_specialty_description"
set RS = Conn.execute(strSQL)
Response.Write "<select name=spec_code ><option value='''' selected>Please Select</option>"
Do While Not RS.EOF
Response.Write "<option value=''" & RS("spec_code") &"''>"& RS("spec_code") &"</option>"
RS.MoveNext
Loop
Response.Write "</select>"
Rs.Close
conn.Close
%>
</body>
</html>
Any JS experts able to help???
Thanks
Fiorano1
|
|
|
|
Hi,
Well you want to put a value in textbox when the listbox value was change ok. Use the following code
<Script language='javascript' type='text/javacript'>
function DispalyVal(obj){
var textbox=document.getElementById('txtVal');
textbox.value=obj.value;
textbox.focus();
return true
}
and change the asp code as follows
Response.Write "<select name=spec_code onchange='return DispalyVal(this)' ><option value='''' selected>Please Select</option>"
Do While Not RS.EOF
Response.Write "<option value=''" & RS("spec_code") &"''>"& RS("spec_code") &"</option>"
RS.MoveNext
Loop
Response.Write "</select><input type='text' name='textVal' id='textVal' value=''>"
Baskar
www.smartwebby.com
|
|
|
|
Script language='javascript' type='text/javacript'>
function DispalyVal(obj){
var textbox=document.getElementById('txtVal');
textbox.value=obj.value;
textbox.focus();
return true
}
|
|
|
|
If a page is loading and there is a network stall, then the initial chunk of HTML can be displayed but the Edwards technique will leave the page exposed. This problem points out the technique is not a complete solution to the problem. The great thing the script has done is allow people to explore the unobtrusive style because the technique does usually work scooter insurance.
My main concern is that the technique is based on counter-standards behavior and should break with new browsers. Imagine being the manager of a site with 150 000 lines of legacy JavaScript with code life expectancy of three years. Over a three year period, modernize that code base and on every page at least partly depend on the Edwards technique. Then imagine that the Edwards technique breaks and three years of code is not working. You can fallback on window.onload but all of a sudden you have long exposure which was exactly what was trying to be avoided. Then imagine explaining to the boss the code is based on what at that point will clearly appear to be a hack and the only reason you chose to use the hack was so you could program in a particular style you happen to like auto loans.
Now that I'm exploring efficient implementations of the delegates system I'm amazed at how fast it can be. The delay on an event seems to be only up to ~10ms with ~100 delegate "behaviors" of different event types and doesn't change with the size of the document. Using delegates allows all types of events to go through capture (even on IE) and bubble phases. It allows for controlling the order that handlers run instead of the random order the browser supplies.
Now I'm trying to determine if programming in the behavioral style is what I want to do and can be applied widely or even exclusively in a maintainable way. Any suggested reading bankruptcy records?
a week ago I was playing with fast selectors. I just rearranged my code to do what you want for the element-selector matcher. What my code does is compile a CSS3 selector into a JavaScript function that takes one element as the argument and returns true of false if there is a match.
For example
.fooClass:nth-last-child-of-type(2)
becomes
function(element) {
var batch = (new Date()).getTime() + "_" + Math.random(),
e = element;
var count = 0,
el = e;
var tn = e.tagName;
if (batch != e.parentNode._FORKbatch) {
var els = e.parentNode.childNodes;
for (var i28 = els.length; i28 -- ;) {
if (els[i28].nodeType == 1 && els[i28].tagName === tn) {
var c = ( ++ count) - (2);
els[i28]._FORKflag = (c === 0 ? true: false);
}
}
e.parentNode._FORKbatch = batch;
}
if (e._FORKflag) {
if (e.className && e.className.match(/(?:^|\s+)fooClass(?:\s+|$)/)) {
return true;
} homeowners insurance
}
return false;
|
|
|
|
|
|
|
|