codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Add an OnChange event to an ASP page  fiorano1 at 08:11 on Thursday, December 18, 2008
 

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

  Re: Add an OnChange event to an ASP page  jandus08 at 08:26 on Wednesday, January 21, 2009
 

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


  Re: Add an OnChange event to an ASP page  ariseadi at 11:44 on Friday, April 24, 2009
 

Script language='javascript' type='text/javacript'>
function DispalyVal(obj){
var textbox=document.getElementById('txtVal');
textbox.value=obj.value;
textbox.focus();
return true
}


  Re: Add an OnChange event to an ASP page  jessonerik at 05:59 on Wednesday, October 14, 2009
 

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;









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
• C++
• Re: refresh parent after closing pop up window
• Dynamic Insertion
• Date and Time function around the world???
• Significant Factors
• Perl array access
• Re: huffman encoding and decoding in C++...
• Perl One Liner: Replace {(
• Re: html including php, accessing the functions


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009