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

Javascript function to replace large select statements

Hello all,

I've got a Select that appears 32 times in a single form to choose one of 25 options. I'm looking to replace:

Expand|Select|Wrap|Line Numbers
  1. <select name="name">
  2.   <option selected value="1"></option>
  3.   <option value="2"></option>
  4. .
  5. .
  6. .
  7.   <option  value="25"></option>
  8. </select>

with a function call to generate the a drop-down list eliminating pages and pages of identical crap which takes some time to load. I think onFocus() could call this notional function, but have no idea how to return the value to an INPUT tag or similar. I'm leaning toward a text file that get populated by the form on page load, and the value changed by choosing an element from the function's pop up or pull down control.

Yike. I'm an internals guy hacking Web code. Scary. :-)

Thanks!

-G
May 17 '10 #1
5 1521
Dormilich
8,658 Expert Mod 8TB
I’m not sure, whether the selects are responsible for the loading time … anyway, if that were indeed the case, loading a select via JavaScript would take even longer than loading via HTML. besides that your page would be useless without JS enabled. you could of course employ a server script to do the writing for you, though.

regarding the value passing, before you kill the <select>, save its value and assign that value to the <input> you replace it with.
May 17 '10 #2
Well, no ... There is no server side available -- it's running on an FPGA and resources are very, very limited.

The select works fine, but 27 lines of code, pasted 32 times takes a while to load. Like I said, it's a tiny device with a Web interface and is s-l-o-w.

I figure calling a function and having that code appear once would be faster by quite a lot.

The mechanization I'm trying to understand is that of a pull-out menu. If you mouseover a pull-out menu in Jscript, it slides out and offers you choices. You can then pick one, and motor along. Changing the event to onFocus instead of mouseover gets me where I need to be -- a popup control that takes user input.

Question is how to implement that simply. I see a lot of bloated code, and I'm trying to avoid spending a week learning Jscript for one little hack. May have to do it, though. Hope not!

Thanks, all ...

Any thoughts?
May 17 '10 #3
Dormilich
8,658 Expert Mod 8TB
if you can auto-generate the content, then JavaScript may indeed be faster*, but it also depends on how fast JS runs on your device.

rule of thumb—the better it looks, the more code you require.

* - it doesn’t matter whether the dropdown code comes from the HTML source or from JS, the time you need to display/create it, should be similar. the question is, is it faster to download the HTML source, or the JS source & data.
May 17 '10 #4
You're precisely right of course ... It appears the best way to do this is via CSS, in fact. Sigh. I'm so not a Web guy.
May 17 '10 #5
Dormilich
8,658 Expert Mod 8TB
It’s hard for me to judge your system, there are so many dependencies, that I can’t tell, which is the fastes way.
May 17 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: gekoblu | last post by:
Hi!, I want to fix via javascript the combo width to a fix value. I'd like to implement a kind of ALT / TITLE function to show the entire option when the text is longer than the combo width......
7
by: Richard Trahan | last post by:
I need a javascript function to hex-encode a plus sign so I can pass the plus sign as an argument in a GET request. escape() and encodeURI() don't do it (and probably shouldn't, because '+' is a...
13
by: kevinold | last post by:
Hello everyone, I have a list of about 1600 employees that I'd like to have displayed in a form. I'd like to make the "search" for the user as easy as possible. I ran across this:...
2
by: David Emme | last post by:
Access 97 I have a number of SELECT statements which contain references to user-defined VBA functions. These typically work as expected, but occasionally, on one user's machine or another,...
1
by: Braden.Bowers | last post by:
I have a page with sets of html select statements. The first one is a drop down list with a bunch of items. I need an onclick statement using java that will take the selected item and put it in my...
6
by: Ajit Goel | last post by:
Hi; We have a Javascript function which I have been tasked to move to a CSharp class. This javascript function uses Regular expression extensively. This function has a string input parameter and...
4
by: sajithkahawatta | last post by:
i want to call a java script function from code behind. in page1.aspx page i placed script' <script language="javascript"> function SetSelected() { infoTextBox.select(); } </script>
1
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
0
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
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...
0
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,...

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.