COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### New form of equal_range()

• Email
• Follow

Hi

// Previously posted by myself on microsoft.public.vc.stl as a variant

Say I have vector<int>, it is sorted, there maybe duplicates and
I wish to find the range [begin, end) of int 75.

I can do

vector<int>    v;
pair<vector<int>::iterator, vector<int>::iterator> range;
vector<int>::iterator it1, it2;

// populate vector here

range = equal_range(v.begin(), v.end(), 75);

and now the iterator range [range.first, range.second) is a STL range to any
instances of 75.
So far, so good.

But now suppose I wish to find the range [51, 100). Now what?
It seems I can only do this in 2 steps:

it1 = lower_bound(v.begin(), v.end(), 51);
it2 = upper_bound(v.begin(), v.end(), 100);

I can't do this using equal_range(), or can I?

It is a shame there is not

range = equal_range(v.begin(), v.end(), object1, object2);
range = equal_range(v.begin(), v.end(), object1, object2, predicate());

as part of the library where as a precondition, either
object1 < object2
or
!predicate(object2, object1)
is true.

Thanks

Stephen Howe

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply Stephen 1/26/2005 9:52:21 AM

See related articles to this posting

Stephen Howe wrote:
>Say I have vector<int>, it is sorted, there maybe duplicates and
>I wish to find the range [begin, end) of int 75.
>
>I can do
....
>
>range = equal_range(v.begin(), v.end(), 75);
>
>and now the iterator range [range.first, range.second) is a STL range to any
>instances of 75.
>So far, so good.
>
>But now suppose I wish to find the range [51, 100). Now what?

You can define a predicate that compares to a range instead of a
specific value.

class range_pred {
typedef std::pair<int, int> data;
public:
bool operator()(data d, int val) const
{
return val < d.first || val > d.second;
}

bool operator()(int val, data d) const
{
return (*this)(d, val);
}
};

// and use it this way
range = equal_range(v.begin(), v.end(),
std::make_pair(51, 100), range_pred());

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply Motti 1/26/2005 6:59:15 PM

Stephen Howe wrote:
> <snip>
>
> But now suppose I wish to find the range [51, 100). Now what?
> It seems I can only do this in 2 steps:
>
> it1 = lower_bound(v.begin(), v.end(), 51);
> it2 = upper_bound(v.begin(), v.end(), 100);
>
> I can't do this using equal_range(), or can I?
>

You can do it be writing your own predicate, basically write it so that
it treats all numbers in the range [51,100) as equal.

something like (note: I haven't tried compiling this.. sorry!)
template<int lower, int upper>
struct range_predicate {
bool operator()(int i,int j) {
if(lower<=i && i<upper && lower<=j && j<upper) return false;
return i<j;
}
};

then do
range = equal_range(v.begin, v.end(), range_predicate<50,100>());

Although I will admit this isn't as nice as it could be...

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply Bob 1/26/2005 7:22:56 PM

Stephen Howe wrote:
> Hi
....
> range = equal_range(v.begin(), v.end(), 75);
>
> and now the iterator range [range.first, range.second) is a STL range
to any
> instances of 75. So far, so good.
>
> But now suppose I wish to find the range [51, 100). Now what?
> It seems I can only do this in 2 steps:
>
> it1 = lower_bound(v.begin(), v.end(), 51);
> it2 = upper_bound(v.begin(), v.end(), 100);
>
> I can't do this using equal_range(), or can I?

No, and it seems rather obvious to me. 51 is not equal to 100, and
*it1 is not equal to *it2.

BTW, try
it1 = lower_bound(v.begin(), v.end(), 51);
it2 = upper_bound(it1, v.end(), 100);

No need to search for the value 100 in the range [v.begin(), it1]
HTH,
Michiel Salters

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply msalters 1/26/2005 7:31:27 PM

"Stephen Howe" <sjhoweATdialDOTpipexDOTcom@eu.uu.net> wrote in message
news:41f7170a$0$311$cc9e4d1f@news.dial.pipex.com... > It is a shame there is not > > range = equal_range(v.begin(), v.end(), object1, object2); > range = equal_range(v.begin(), v.end(), object1, object2, predicate()); > > as part of the library where as a precondition, either > object1 < object2 > or > !predicate(object2, object1) > is true. Why? Is that really such a common operation? Is it so difficult to write it1 = lower_bound(v.begin(), v.end(), object1); it2 = upper_bound(it1, v.end(), object2); ? If there were a form of equal_range that took two objects, would you also want one that took three? [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]   0 Reply Andrew 1/26/2005 8:51:39 PM > If there were a form of equal_range that took two objects, would you also > want one that took three? No. It is the fact that 2 objects searched for would be the limits of an stl range. What would it mean with 3 objects? But I guess this is non-standard as no other algorithm takes a pair of objects. The other reason for asking is the the complexity requirements for such an equal_range() might be lower than lower_bound() combined with upper_bound(). I have not sat and analysed this yet. Stephen Howe [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]   0 Reply Stephen 1/27/2005 12:52:05 PM On 26 Jan 2005 04:52:21 -0500, "Stephen Howe" <sjhoweATdialDOTpipexDOTcom@eu.uu.net> wrote: > Say I have vector<int>, it is sorted, there maybe duplicates and > But now suppose I wish to find the range [51, 100). Now what? > It seems I can only do this in 2 steps: > it1 = lower_bound(v.begin(), v.end(), 51); > it2 = upper_bound(v.begin(), v.end(), 100); This gives you [51, 100]. If you really want [51, 100) you need lower_bound for the second also. > I can't do this using equal_range(), or can I? Yes you can. It needs a predicate and careful use. I assume a range of the form [,). template <class T> struct Comp { T b, e; Comp (T b, T e) : b(b), e(e) { assert(b <= e); } bool operator() (T lhs, T rhs) { return lhs == b ? ! (rhs < e) : lhs < b; } }; std::equal_range(v.begin(), v.end(), 51, Comp<int>(51, 100)); Why not just write the algorithm you want? template <class I, class T> std::pair<I, I> equal_range(I first, I past, T b, T e) { I f(std::lower_bound(first, past, b)); return std::pair<I, I>(f, std::lower_bound(f, past, e)); } It does seem to be less complicated. If you really think the combined search of std::equal_range will be significantly better, you could just code it with the Comp. template <class I, class T> std::pair<I, I> equal_range(I first, I past, T b, T e) { return std::equal_range(first, past, b, Comp<T>(b, e)); } John [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]   0 Reply John 1/27/2005 12:52:45 PM > BTW, try > it1 = lower_bound(v.begin(), v.end(), 51); > it2 = upper_bound(it1, v.end(), 100); Yes. That occured to me after I posted. It reduces the compares. Thanks Stephen Howe [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]   0 Reply Stephen 1/27/2005 12:54:39 PM "Andrew Koenig" <ark@acm.org> writes: > "Stephen Howe" <sjhoweATdialDOTpipexDOTcom@eu.uu.net> wrote in message > news:41f7170a$0$311$cc9e4d1f@news.dial.pipex.com...
>
>> It is a shame there is not
>>
>> range = equal_range(v.begin(), v.end(), object1, object2);
>> range = equal_range(v.begin(), v.end(), object1, object2, predicate());
>>
>> as part of the library where as a precondition, either
>> object1 < object2
>> or
>> !predicate(object2, object1)
>> is true.
>
> Why?  Is that really such a common operation?  Is it so difficult to write
>
>     it1 = lower_bound(v.begin(), v.end(), object1);
>     it2 = upper_bound(it1, v.end(), object2);
>
> ?
>
> If there were a form of equal_range that took two objects, would you also
> want one that took three?

I'm not sure what that would mean, but the semantics of the two-object
case are achievable now that we've made heterogeneous comparison
operators legal with equal_range et. al.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply David 1/27/2005 12:55:23 PM

On 26 Jan 2005 13:59:15 -0500, Motti Lanzkron <mlanzkron@yahoo.co.uk>
wrote:

> Stephen Howe wrote:

> >But now suppose I wish to find the range [51, 100). Now what?

> You can define a predicate that compares to a range instead of a
> specific value.

> class range_pred {
>       typedef std::pair<int, int> data;
> public:
>       bool operator()(data d, int val) const
>       {
>               return val < d.first || val > d.second;
>       }
>
>       bool operator()(int val, data d) const
>       {
>               return (*this)(d, val);
>       }
> };

> // and use it this way
> range = equal_range(v.begin(), v.end(),
>                                       std::make_pair(51, 100), range_pred());

Not bad, but try compiling it with a fussy compiler like comeau.
Hint:

std::vector<unsigned> v;
std::equal_range(v.begin(), v.end(), 42);

fails.

John

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply John 1/27/2005 12:56:30 PM

Motti Lanzkron wrote:
> Stephen Howe wrote:
>
>>Say I have vector<int>, it is sorted, there maybe duplicates and
>>I wish to find the range [begin, end) of int 75.
>>
>>I can do
>
> ....
>
>>range = equal_range(v.begin(), v.end(), 75);
>>
>>and now the iterator range [range.first, range.second) is a STL range to any
>>instances of 75.
>>So far, so good.
>>
>>But now suppose I wish to find the range [51, 100). Now what?
>
>
> You can define a predicate that compares to a range instead of a
> specific value.
>
> class range_pred {
>       typedef std::pair<int, int> data;
> public:
>       bool operator()(data d, int val) const
>       {
>               return val < d.first || val > d.second;
>       }
>
>       bool operator()(int val, data d) const
>       {
>               return (*this)(d, val);
>       }
> };
>
> // and use it this way
> range = equal_range(v.begin(), v.end(),
>                     std::make_pair(51, 100), range_pred());

Shouldn't that be:

class range_pred {
typedef std::pair<int, int> data;
public:
bool operator()(data d, int val) const
{
return val > d.second;
}

bool operator()(int val, data d) const
{
return val < d.first;
}
};

After all, the predicate is testing less-than, not containment.

While I consider this to be the best solution, I do not see how it is
portable.  equal_range requires the container to be considered sorted
with the predicate specified, and this predicate can not be applied to
the container!

-- MJF

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply M 1/27/2005 1:07:47 PM

I would consider std::subrange(It1,It2,lower,upper) much less esoteric
than, say, random_shuffle, even though I agree that it is not so
terrible to have to do it in two statements.

Cheers,
Nicola Musatti

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply Nicola 1/27/2005 8:48:43 PM

John Potter wrote:
>
>Not bad, but try compiling it with a fussy compiler like comeau.
>Hint:
>
>    std::vector<unsigned> v;
>    std::equal_range(v.begin(), v.end(), 42);
>
>fails.

I'm looking at the standard now and I see:

template<class ForwardIterator, class T>
pair<ForwardIterator, ForwardIterator>
equal_range(ForwardIterator, ForwardIterator, const T&);

Where does it require that T be the same type as *ForwardIterator ?

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply Motti 1/27/2005 8:56:05 PM

>> it1 = lower_bound(v.begin(), v.end(), 51);
>> it2 = upper_bound(v.begin(), v.end(), 100);
>
> This gives you [51, 100].  If you really want [51, 100) you need
> lower_bound for the second also.

Thanks John. The code is right, my maths notation is wrong. I should have
[51, 100+1). But I guess on thinking that the 2nd object should be
non-inclusive limit so that it matches the general form of ranges in the
library.

Stephen Howe

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply Stephen 1/27/2005 8:58:18 PM

John Potter <jpotter@lhup.edu> writes:

> Not bad, but try compiling it with a fussy compiler like comeau.
> Hint:
>
>     std::vector<unsigned> v;
>     std::equal_range(v.begin(), v.end(), 42);
>
> fails.

But Comeau is now officially "too fussy."
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#270

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply David 1/27/2005 9:30:46 PM

On 27 Jan 2005 16:30:46 -0500, David Abrahams
<dave@boost-consulting.com> wrote:

> John Potter <jpotter@lhup.edu> writes:

> > Not bad, but try compiling it with a fussy compiler like comeau.
> > Hint:
> >
> >     std::vector<unsigned> v;
> >     std::equal_range(v.begin(), v.end(), 42);

> > fails.

> But Comeau is now officially "too fussy."
> http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#270

Status WP.  Comeau will be "too fussy" when and if the WP becomes
a standard with those words still intact.  I wish I could file a
bug report on Comeau today.

John

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply John 1/28/2005 12:36:40 AM

On 27 Jan 2005 15:56:05 -0500, Motti Lanzkron <mlanzkron@yahoo.co.uk>
wrote:

> John Potter wrote:

> >Not bad, but try compiling it with a fussy compiler like comeau.
> >Hint:

> >    std::vector<unsigned> v;
> >    std::equal_range(v.begin(), v.end(), 42);

> >fails.

> I'm looking at the standard now and I see:

> template<class ForwardIterator, class T>
> pair<ForwardIterator, ForwardIterator>
> equal_range(ForwardIterator, ForwardIterator, const T&);

> Where does it require that T be the same type as *ForwardIterator ?

It seems to be indicated in 25.3.3/1.  Some think that the following
is a valid implementation.

template <class T>
struct __less {
bool operator() (T const& lhs, T const& rhs) {
return lhs < rhs;
}
};
template <class FI, class T>
pair<FI, FI> equal_range (FI f, FI p, T const& v) {
return equal_range(f, p, v, __less<T>());
}

Some also think that had things been better understood, it would
have been

template <class FI>
pair<FI, FI> equal_range(FI, FI, typename
iterator_traits<FI>::value_type const&);

That, of course is all history.  The only important question today
is whether you want your code to compile today on fussy compilers.

John

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply John 1/28/2005 12:37:47 AM

Stephen Howe wrote:

>>> it1 = lower_bound(v.begin(), v.end(), 51);
>>> it2 = upper_bound(v.begin(), v.end(), 100);
>>
>> This gives you [51, 100].  If you really want [51, 100) you
>> need lower_bound for the second also.
>
> Thanks John. The code is right, my maths notation is wrong. I
> should have [51, 100+1). But I guess on thinking that the 2nd
> object should be non-inclusive limit so that it matches the
> general form of ranges in the library.

Past-the-end iterators are supposed always to exist, but what is past
the end of int's range?

--
Quidquid latine dictum sit, altum viditur.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply Martin 1/29/2005 4:55:25 AM

On 28 Jan 2005 23:55:25 -0500, Martin Eisenberg
<martin.eisenberg@udo.edu> wrote:

> Stephen Howe wrote:

> >>> it1 = lower_bound(v.begin(), v.end(), 51);
> >>> it2 = upper_bound(v.begin(), v.end(), 100);

> >> This gives you [51, 100].  If you really want [51, 100) you
> >> need lower_bound for the second also.

> > Thanks John. The code is right, my maths notation is wrong. I
> > should have [51, 100+1). But I guess on thinking that the 2nd
> > object should be non-inclusive limit so that it matches the
> > general form of ranges in the library.

> Past-the-end iterators are supposed always to exist, but what is past
> the end of int's range?

The choice is either to pick one or use [,] preventing an empty range.
A very old problem for full range of anything.  do-while for complete
range of any integral type prevents zero executions.  You can't have
both.

John

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply John 1/29/2005 3:29:34 PM

John Potter wrote:

> On 28 Jan 2005 23:55:25 -0500, Martin Eisenberg
> <martin.eisenberg@udo.edu> wrote:

>> Past-the-end iterators are supposed always to exist, but what
>> is past the end of int's range?
>
> The choice is either to pick one or use [,] preventing an empty
> range. A very old problem for full range of anything.  do-while
> for complete range of any integral type prevents zero
> executions.  You can't have both.

What about the mathematical convention that sum_{i=m}^n a_i = 0
for m > n? The programming analog would break down for a type with
just one value, oh well. (I acknowledge that there is another
convention making the sum zero only for m = n + 1.)

--
Quidquid latine dictum sit, altum viditur.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Reply Martin 2/3/2005 9:43:03 PM

19 Replies
230 Views

Similar Articles

12/7/2013 5:16:09 AM
[PageSpeed]

Similar Artilces:

Letter form
--nextPart2690225.MJUkQgaUhv Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8Bit I am trying to make a letter form for private letters, and I don't much like the standard form, which wastes much of the page. I have been advised to use a Koma type, and found a "recipe" that comes towards what I want. I attach a file based on that. However, there are a few problems, after compiling with LaTeX: 1. My own address is presented twice; once in a block at the top left, and again in the only form I want, a single underlined line. How do I get rid of that extra...} % styrer fontstoerrelse \addtokomafont{backaddress}{\Large} \begin{document} \begin{letter}{% To Whom\\it may concern\\2701 Some Street\\32768 Anytown} \setkomavar{subject}{Lorem ipsum} \opening{Dear XX} \lipsum[1] \closing{Regards} \end{letter}% \end{document} --nextPart2690225.MJUkQgaUhv-- Dieter Britz schrieb: > I am trying to make a letter form for private letters, and I don't much > like the standard form, which wastes much of the page. I have been advised > to use a Koma type, and found a "recipe" that comes towards what I want. > I attach a file based

Problem with a form!
navegador no soporta JavaScript&reg;</p> </noscript> </head> <body> <h1 class=3D"toctitle">Plaza</h1> <form name=3D"formulario" action=3D"" method=3D"post" enctype=3D"text/plain" target=3D"mainframe"> <table width=3D"200" border=3D"0"> <tr> <td>Plaza</td> <td><select name=3D"plaza" id=3D"plaza"> <option value=3D0>Monterrey</option> <option value=3D1>Valle de M=C3=A9xico</option>..._cond.htm"], ["puebla_cluster.htm", "puebla_cond.htm"], ["nvo_laredo_cluster.htm", "nvo_laredo_cond.htm"] ]; documento =3D DOC[+a.plaza.value][+a.tipo.value]; camino =3D (carpeta + '/' + documento + '#' + pregunta); }; </script> <noscript> <p>Su navegador no soporta JavaScript&reg;</p> </noscript> </head> <body> <h1 class=3D"toctitle">Plaza</h1> <!-- Inicia el Formulario --> <form name=3D"formulario" action=3D"" method=3D"

Affidavit form
Hi all, I am trying to write an affidavit and I can't find a template in latex. Does anybody know where I can get one? Thank you

Dynamic Form
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when they press next the form generates "How old are you?" 5 times on the page. The customer will answer all 5 questions then press next. Finally, all the local variables get dynamically created and written to a database. I have already taken care of dynamically creating the question five times. Using a simple WHILE clause, this generates the correct number of questions. What I am having an issue with at this point, is how to dynamically create the local variables.For instance, for the question "How old are you?" I would need a unique variable for each instance; using something like $Age(n). So that for five times, it would automatically created variables$Age1 through $Age5. I have carried over the number to the submit page by creating the variable$Number and passing it along as hidden button on the form. $Age'$Number' seemed to work for creating the variable, but $_post["Age'$Number'"] doesn't work for referencing the global variable. I would

Form and If command
Dear All, I'm new in the Php world and am trying to do my first trials (with included errors :). At the present I created a simple form: <FORM METHOD="POST" ACTION="test.php"> <INPUT TYPE="text" NAME="amount" SIZE="10" MAXLENGHT="20"> <INPUT TYPE="SUBMIT" VALUE="SUBMIT"> </FORM> Then, in the test.php page I've included the following code: <?php echo $_REQUEST["amount"]; ?> In the field "amount" of the form it will be inserted a number. I'd like to create a string which make the following operations: if the inserted amount is < or = to 1 go to the URL http://www..... if the inserted amount is > 1 go to the URL http://www..... I've some problem because don't know if I can use something like "if "amount = 1 ... " or not. Can you help me please? Many thanks. All the best, Nico Nico wrote: > Dear All, > > I'm new in the Php world and am trying to do my first trials (with > included errors :). > At the present I created a simple form: > > <FORM METHOD="POST" ACTION Line on a form , text, etc. These can be drawn by code or you can allow end-user to draw. Let's say you have a line in the MetaDraw control. By setting EditMode = ED_Rotate you allow the end-user to click on and rotate the line. You can then trap the Change event and identify the new position to display this in a textbox See the following web page to see this working http://www.Btis.com/btproducts/metadraw/WebSamples/MD3-shape-Rotation/MD3-Shape-Rotation.htm Here is the code for a VB project A) Just add a MetaDraw control ( MetaDraw1 ) and a textbox ( Text1) to a VB 6 form B) Insert the following code Private Sub Form_Load() With MetaDraw1 ' Add a line at some initial position and angle .AddObject OT_LINE, 100, 100, 200, 200 Text1.Caption = .ObjRotation ' Allow user to rotate but not otherwise move the line .EditMode = ED_ROTATE .EditFlags = MetaDraw1.EditFlags And Not EFLG_MOVE End With End Sub Private Sub MetaDraw1_Change(ByVal ChangeType As Integer Link Form Okay, so I've created a form2 that automatically inserts data from a table (one of access's default methods). form2 has the ability to change record to record so I can view different records (the arrows on the bottom left hand corner make this doable). Anyway, my question is, let's say I have 5 records in the table. And my primary key is the model number of a certain device. How can I make a link from form1 (which I know how to create a link) but have the link specifically go to record three of the form2? And I do not want to just link from form1 to form2 then have t getelementbyid on a form My apologies to all I am new to perl, wondering if this is possible using the method getelementbyid: If I had javascript code on a page containing a form field and I wanted to fill in this field, how would I utilise getelementbyid if the javascript eg is: <tr> <td class="row1"><span class="gen"><b>Username</b></span></td> <td class="row2"><span class="genmed"><input type="text" class="post" tabindex="1" name="username" size="25" maxlength="25" value="" /></span></td> </tr> and I wanted to fill the form field username$mech->field ('username', $username); somehow wouldn't work, but I am unsure as to how to use getelementbyid. Nospam wrote: > My apologies to all I am new to perl, wondering if this is possible using > the method getelementbyid: > > If I had javascript code on a page containing a form field and I wanted to > fill in this field, how would I utilise getelementbyid if the javascript eg > is: > > <tr> > <td class=" A picture on a form I have a random access file with information of people with people.ID as a unique field. I also have pictures of these people named by their ID, e.g. the person with ID 1 will have a picture named 1.jpeg. On a form I have a drop-down list which displays the peoples' IDs and an Image1. When I select an ID from the list, I would like the Image1 to display the picture. I've tried this in the click event of the drop-down list which doesn't work: cboID.Text = PersonID Image1.Picture = App.Path & "\"PersonID".jpeg" Could someone help me to do this? Thank you "james" <ds@hotmail.com> wrote in message news:djq36g$kh\$1@newsg1.svr.pol.co.uk... > When I select an ID from the list, I would like the Image1 > to display the picture. I've tried this in the click event of the > drop-down list which doesn't work > cboID.Text = PersonID > Image1.Picture = App.Path & "\"PersonID".jpeg" When posting questions you really need to be a bit more specific. Instead of simply saying "it doesn't work" you should tell us *why* it doesn't work (the error message you are getting

Filter by Form
Is there a way to program the filter by form view so I can customise it? Phil You can't "program the filter by form view", but you can very easily create a form for entering values from which you can create a query to "filter" the results. It really makes sense to thoughtfully design your database applications rather than trying to "adapt" the end-user capabilities and rely on the user to know how they should be used. Larry Linson Microsoft Office Access MVP "Phil Rushton" <phil.rushton@age-concern-cardiff.org.uk> wrote in message news:0bSdndqmzOYR0__QnZ2dnUVZ8sOdnZ2d@bt.com... > Is there a way to program the filter by form view so I can customise it? > > Phil > On 22/02/2011 04:26:58, "Access Developer" wrote: > You can't "program the filter by form view", but you can very easily > create a form for entering values from which you can create a query to > "filter" the results. It really makes sense to thoughtfully design your > database applications rather than trying to "adapt" the end-user > capabilities and rely