473,383 Members | 1,834 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,383 software developers and data experts.

Server Side Javascript option Select Problem

Im having trouble with server side ASP with Javascript.
I have an ADO recordset that returns a list of Times example: 7:00AM. I
then populate the option box with the results. (see below) The problem
is I have a variable called Item_Start, that contains a time that is
determined from another procedure. I simply wish to auto select the
option if it is found. This all happens when the page loads.
You can see below I tried, but it failed. How do I do this with
Javascript? Im not very good with Java at all..so please correct. Say
that item_start = 1:00AM and there IS a 1:00AM in one of the recordset
items ADO_RS("Times"). I simply wish to have the 1:00AM selected in the
dropdown when the page loads.

<%while (!ADO_RS.EOF)
{ %>
<option VALUE ="<%if (item_start == ADO_RS("Times"))
Response.Write(" selected
");%><%=ADO_RS("Times")%>"><%=ADO_RS("Times")% ></option>
<% ADO_RS.movenext();}
ADO_RS.Close(); %>

thanks all !
Eric Tuomikoski

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
2 2081
Eric Tuomikoski wrote:
Im having trouble with server side ASP with Javascript.
I have an ADO recordset that returns a list of Times example: 7:00AM.
I then populate the option box with the results. (see below) The
problem is I have a variable called Item_Start, that contains a time
that is determined from another procedure. I simply wish to auto
select the option if it is found. This all happens when the page
loads.
You have a conceptual problem here. The page "loads" into a browser. The
ASP creates the HTML contents of an HTTP response first, that response
is then sent to the browser, at which point it loads, by which time your
server-side script is long finished.
You can see below I tried, but it failed. How do I do this with
Javascript? Im not very good with Java at all..so please correct.
OK. Java and javascript are distinct programming languages that share
nothing but some characters in their names and syntax that is
reminiscent of C in both cases.
Say that item_start = 1:00AM and
there IS a 1:00AM in one of the recordset
items ADO_RS("Times"). I simply wish to have the 1:00AM
selected in the dropdown when the page loads.
ASP generates HTML (mostly) and sends that HTML to a browser (or maybe
other client). Much of the time problems with server-side scripts can be
diagnosed by viewing the HTML they generate using a view-source facility
in the browser, and doing so in this case probably would have indicated
the problem.
<%while (!ADO_RS.EOF)
{ %>
<option VALUE ="
Output value attribute, equals sign and opening quote.
<%if (item_start == ADO_RS("Times")) Response.Write(" selected");%>
If the - item_start - variable (string?) equals the value returnd from -
ADO_RS("Times") - output a space and the word 'selected'.
<%=ADO_RS("Times")%>">


output the string returned from a call to - ADO_RS("Times") - followed
by another double quote and '>'.

At this point, if - item_start - equalled '1:00AM' and -
ADO_RS("Times") - returned '1:00AM' the HTML for the opening OPTION tag
looks like:-

<option VALUE =" selected1:00AM">

And that is valid, but not at all what you wanted. Move the ASP
expression tag that outputs ' selected' to after the double quote that
ends the VALUE attribute.

Get used to viewing the source in the browser while writing ASP and you
will be able to see when what your output is not what you intended to
output.

Richard.
Jul 23 '05 #2
Perfect. Thanks Richard.

Eric Tuomikoski

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
6
by: Valerian John | last post by:
I have a ListBox webcontrol on an aspx page. Items are added to the ListBox using client-side code. However, when the page is posted back the items are missing/not available. (It is like the...
0
by: Sileesh | last post by:
Hi I have html table and a Button in an Aspx page. I am adding one row with some textboxes to Html table each time i click on the Button thru Javascript. Now problem is when when i try to...
3
by: The Developer | last post by:
Hi All, I have a web application where I am adding a custom attribute to my ASP.NET text box control and changing value of that attribute at client side using JavaScript. My problem is that...
7
by: Alex Maghen | last post by:
I have some client-side JavaScript that I want to run whenever a pulldown <SELECT> is changes on th client. I'm trying to do this as follows... <select id="MyPulldown"...
10
by: Paul | last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a server. I have a browse to find the file on the server but need to create the path dynamically as to were it will go...
9
by: jazzslider | last post by:
I have a headache. I've done a LOT of research lately into XForms, and I am thoroughly convinced that a good implementation of this technology would help me immensely in converting my...
3
by: balurajeev | last post by:
Hii, currently i am working on an apliction(ASP.NET/C#) that creates dynamic html rows which contain six html text boxes and a html dropdowllist. At the time of page load the web page contain six...
3
by: graphicssl | last post by:
Okay, so first of all, I'm a designer first and a light coder second (I'm only really trained with HTML and CSS). So I apologize for having to post about something that's probably super-trivial! ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.