views:

63

answers:

2

In a HTML form user is expect to fill / select some data and trigger an action probably a http-post.

If your only requested data field is a "2 digit" you can use html text input element get some data.

Then you want to make it useful; enable user easily select data from a 'html select'

But not all of your data is well-ordered so eye-searching within these data is somehow cumbersome. Because your data is meaningful with its relations. If there is no primary key for foreign key "12" it should not be shown. Vice versa if this foreign key occurs a lot, then it has some weight and could be displayed with more importance.

So, what will be your way?

a) Use text input to get data and validate it with regex, javascript, ...

b) Use some dropdown select.

c) Any other way ?

Any answer will appreciated :)

A: 

I'd suggest the best of both worlds - a combo box. Unfortunately, not supported in html out of the box, so you'd need some javascripting.

stereofrog
A: 
<input type="text" id="check_id" size="2" maxlength="2" />

and javascript validation

if(is_num(document.getElementByID(check_id))) { bla bla }
gmunkhbaatarmn
`Id`, not `ID`, `'check_id'`, not `check_id`, `is_num` is not a built in JS function, client side sanity checking should come after server side checking. *bla bla* isn't all that helpful.
David Dorward
ok, I was mistaken. getElementById.is_num() is user defined function, like:function is_num(user_var) { return ((user_var) == Number(user_var)) }
gmunkhbaatarmn