473,588 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2097
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("Tim es")%>">


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
4324
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 vbscript reads the database and populates a listbox on the page with the first field from each record in the recordset. This works fine. - User selects an option on the listbox and, using the OnChange, I
6
6499
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 page does not know the items were added client-side.) TIA, Val
0
1867
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 collect the data in the Textboxes which i added dynamically from server side, i am not able to do . Alos i tried to bedug, the total no of rows in Html table does not reflect the dynamically added rows.
3
3529
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 changed value of that custom attribute is not reflecting back at server side. Any ideas about this problem? Server side code: private void Page_Load(object sender, EventArgs e) { if (this.IsPostBack == false)
7
6277
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" onchange="handleProblemChange();" runat="server"> If I do this, I get client-side javascript errors because the id "MyPulldown" doesn't exist. It's been mangled into this crazy-named thing that I can't use. How do I fix this so that the ID that I give it ends up being...
10
2249
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 based on some dropdown boxes, one for the year and one for the month. This line saves the file so I am trying to get the month and year from the dropdown boxes and put them in the month and year variables but this does not work,...
9
2371
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 department's paper forms into interactive online systems. There are a couple of problems I'm facing that I'm hoping someone here could help with. Number one: browser support for XForms is pitiful, and I can't expect my target audience to download...
3
2997
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 server side text boxes and a serverside drop down list. and a html "Addrow" buton which create client side textboxes and dropdown list dynamichally Now i am meeting a problem of passing values from dynamichally created html controls to Server Side...
3
3592
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! I'm working on setting up a shopping cart for a one-product web site, and I'm using HTML and CSS, with ASP for the shopping cart. The ASP takes the information from the form on the shopping cart, and formats it in to two e-mails: one for the company...
0
7927
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7857
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
8220
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...
1
7981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8222
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...
1
5723
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
5396
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
3846
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...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.