473,804 Members | 3,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing meta-knowledge about a form element

I need to create a table where each element has certain specific properties.

For example, elements in the first column should always have a range of
0-100, and increment by 1. Elements in column 2 might have a range of
0-360, and increment by 0.1. Altogether there might be 8 elements in
each row.

Since this is basically the same javascript function over and over, I
wonder if there is a way to create some <input> element that might
contain this knowledge in a way that javascript can access it.

For example, could I have

<input type="text" class="percent" onkeypress="jav ascript:blah(ev ent)">

where the javascript function could retrieve the class value?

Since this is going to be fairly complex, I'd like to make it fairly
self-documenting and simple. It's much easier for a maintainer to
understand class="precent" than "javascript:bla h(0,100,1,event )",
especially since I am also going to have to pass navigation information
(is this a border element in the table? what are my neighbors? kind
of information... - so that the actual information might end up being
javascript:blah (0,100,1,5,21,1 6,18,0,1,0,0,ev ent) to denote the data
type, the 4 neighbors, and the 4 border conditions....
Jan 20 '06 #1
3 1609
VK

Captain Dondo wrote:
I need to create a table where each element has certain specific properties.

For example, elements in the first column should always have a range of
0-100, and increment by 1. Elements in column 2 might have a range of
0-360, and increment by 0.1. Altogether there might be 8 elements in
each row.

Since this is basically the same javascript function over and over, I
wonder if there is a way to create some <input> element that might
contain this knowledge in a way that javascript can access it.

For example, could I have

<input type="text" class="percent" onkeypress="jav ascript:blah(ev ent)">

where the javascript function could retrieve the class value?


Yes, you can. Though DOM doesn't provide a native method like
getElementsByCl assName, but you can write one or use any of already
written of this kind. Also if it's given what you are working only with
inputs within one form, then the task even more simple:

<input type="text" class="percent" onkeypress="bla h(event)">
(please note that event handler is not a link, so javascript:
pseudo-protocol is out of business here)
....
var elm = document.form['myForm'].elements;
var len = elm.length;
for (var i=0; i<len; i++) {
switch (elm[i].className) {
case 'percent' :
// your action
break;
case 'degree':
// your action
break;
default:
// no match
}
}
....
you can apply several classes to one element to make the system as
complicated as you want:
<input type="text" class="percent mandatory " onkeypress="bla h(event)">
<input type="text" class="integer positive mandatory"
onkeypress="bla h(event)">
<input type="text" class="integer positive optional"
onkeypress="bla h(event)">
etc.

Jan 20 '06 #2
VK wrote:
Yes, you can. Though DOM doesn't provide a native method like
getElementsByCl assName, but you can write one or use any of already
written of this kind. Also if it's given what you are working only with
inputs within one form, then the task even more simple:

<input type="text" class="percent" onkeypress="bla h(event)">
(please note that event handler is not a link, so javascript:
pseudo-protocol is out of business here)
OK, noted. I am a javascript newbie....
...
var elm = document.form['myForm'].elements;
var len = elm.length;
for (var i=0; i<len; i++) {
switch (elm[i].className) {
case 'percent' :
// your action
break;
case 'degree':
// your action
break;
default:
// no match
}
}
...
you can apply several classes to one element to make the system as
complicated as you want:
<input type="text" class="percent mandatory " onkeypress="bla h(event)">
<input type="text" class="integer positive mandatory"
onkeypress="bla h(event)">
<input type="text" class="integer positive optional"
onkeypress="bla h(event)">
etc.


Very cool.... So I should be able to retrieve taborder values as well
using this method... And perhaps store general data like # of rows and
columns in a hidden element, so then I can derive most of my nav info....

Thanks,

--Yan
Jan 20 '06 #3
VK

Captain Dondo wrote:
So I should be able to retrieve taborder values as well
using this method...


For elements taborder there is native attribute "tabindex", and all
modern browsers (at least all you need to care about, including IE and
FF) respect this attribute:

<input type="text" name="t1" tabindex="1">
<input type="text" name="t2" tabindex="3">
<input type="text" name="t3" tabindex="2">
<input type="text" name="t4" tabindex="-1">

On tab press focus goes from t1 to t3, and only then to t2. The
negative value I used only on IE and it does what promised: such
element is excluded from taborder so requires an explicit mouse click
for focus.

Of course you need to use it only if you need to i) change the default
taborder or ii) exclude some elements from taborder.

And of course you can not only set tabindex but also read it:
var ti = someElement.tab Index;

Jan 20 '06 #4

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

Similar topics

1
4015
by: Cezary | last post by:
Hello. I was read PHP manual, but i'm not sure yet. Here is my meta tags in html: <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-2"> <META HTTP-EQUIV="Expires" CONTENT="0"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
2
12643
by: Jonathan Driller | last post by:
I am attempting to block repeat downloads from a site. I need to have a landing page pass a referer to a secured page. I have tried a meta refresh redirect and several Javascript redirect strategies but none pass the referer. How can I force this since the referer property is read only? I have set up an .htaccess file so it will only let people into a secure directory if they come from an internal page on my site. This is done by...
24
3556
by: Day Bird Loft | last post by:
Web Authoring | Meta-Tags The first thing to understand in regard to Meta Tags is the three most important tags placed in the head of your html documents. They are the title, description, and keyword meta-tags. If you are missing any of these meta-tags you are missing the boat. If you use the following meta-tag formula, and you are not trying to deceive the spiders, I guarantee you will succeed in increasing your placement in the...
9
2799
by: nungon | last post by:
Good morning, I have a web site in which 7 pages repeat once and again in thousands of folders. Why? because I want to keep, to the user view, the pretty url www.myweb.com/username/pageX.asp. As you can imagine, this makes maintenance hard, because when I make some update, I have to run a program to spread the change to the xthousands directories.
3
32909
by: J1C | last post by:
How can I programatically add meta tags with javascript?
3
1363
by: Geoff | last post by:
As a newbie to javascript can someone tell me please how to pass a variable from HTML to Javascript? I have the following script which works OK if I input to str from the "prompt" box, but I want to input from a one-line text box on an HTML page. Thanks in advance. Geoff. <html> <head>
3
1479
by: Bill Nguyen | last post by:
I would like to invoke the IE browser and pass values (lat and long) to function GtMap() the html file below from a VB.NET app. help, please! Thanks Bill ------------------------
50
6507
by: Mikhail Teterin | last post by:
Hello! The sample program below is compiled fine by gcc (with -Wall), but rejected by Sun's SUNWspro compiler (version 6 update 2). The point of contention is, whether a value for one of the union's types can be passed to a function directly -- without creating a separate variable of the union type and assigning the appropriate field of it. Is gcc being too liberal, or is this behavior simply part of a newer
16
2522
by: Edward | last post by:
Hi All, I am having huge problems with a very simple dotnet framework web page (www.gbab.net/ztest3.aspx) , it does NOT render correctly under Apple's Safari. The DIV's do not align amd float as they should, and do in Dotnet. The page is really, really simple, and it has a CSS and with NO masterpage. I have tried using the following as recommendations made earlier in this Newsgroup:-
2
2732
by: baskar1900 | last post by:
Sir, we are trying to pass chinese character through querystring in ASP and we are using chinese windows 2003 server Operating System. when we tried to retrieve using Request.QueryString () we are getting strage unexpected characters. we have given the following setting at the top of the webpage (i.e) before executing query string. <% Response.Codepage = 65001
0
9579
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
10577
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...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10320
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,...
1
7620
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
6853
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
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.