Need help once again :)

G

Guest

Hello,

First of all the help I got from this site, MVPs are just amazing :)
:)...don't know what I would have done without you guys :)

I have a question...On my site, employees login, stores the cookie, then it
takes them to the main page... On main page, it shows their name (Text box),
depending upon the employee name, it should autopopulate 2 other text boxes
with their employee number and telephone#. How can I do that?

Looked for lot of help, but all the help was for combo boxes or drop down,
but in this case I have a text box, and its value determines the value in two
other textboxes.

Any help will be greatly appreciated.
 
T

Trevor L.

shikha said:
Hello,

First of all the help I got from this site, MVPs are just amazing :)
:)...don't know what I would have done without you guys :)

I have a question...On my site, employees login, stores the cookie,
then it takes them to the main page... On main page, it shows their
name (Text box), depending upon the employee name, it should
autopopulate 2 other text boxes with their employee number and
telephone#. How can I do that?

When you say "should", do you mean that you have written code which fails, or that this is what you want it to do.

In either case, you need some Javascript to pick up their names and alter the fields. You may even need a database to store these
details if there are a large number of employees.
Looked for lot of help, but all the help was for combo boxes or drop
down, but in this case I have a text box, and its value determines
the value in two other textboxes.

Any help will be greatly appreciated.

Please post back with the URL or, if it is on intranet, the code (or at least the relevant part of it).
 
G

Guest

Hi Trevor,

Thank your for your help :) No I don't have the written code, I tried
couple of things here and there but didn't work. I tried using if else
statement, but no success, may be I don't know how to use it properly in java
script.

To get their user names, i am using <% =Session("UID") %>, which gives me
their user id from the login page. Currently its for 30 employees, and I
have a database with their information. So I have a text box Associate_Name
which autopopulates by using <% =Session("UID") %>. Now depending upon
Associate_Name, I want it to autopopulate the employee number, and the phone
number.

Then this form will submit the information to the database.

Thanks,

Shikha


Trevor L. said:
shikha said:
Hello,

First of all the help I got from this site, MVPs are just amazing :)
:)...don't know what I would have done without you guys :)

I have a question...On my site, employees login, stores the cookie,
then it takes them to the main page... On main page, it shows their
name (Text box), depending upon the employee name, it should
autopopulate 2 other text boxes with their employee number and
telephone#. How can I do that?

When you say "should", do you mean that you have written code which fails, or that this is what you want it to do.

In either case, you need some Javascript to pick up their names and alter the fields. You may even need a database to store these
details if there are a large number of employees.
Looked for lot of help, but all the help was for combo boxes or drop
down, but in this case I have a text box, and its value determines
the value in two other textboxes.

Any help will be greatly appreciated.

Please post back with the URL or, if it is on intranet, the code (or at least the relevant part of it).
--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
G

Guest

Trevor,

actually i figured it out.. I used java script with if else statement. This
way i had to enter information for all the employees...but atleast it works.

Thank you for looking into this!!!

shikha



shikha said:
Hi Trevor,

Thank your for your help :) No I don't have the written code, I tried
couple of things here and there but didn't work. I tried using if else
statement, but no success, may be I don't know how to use it properly in java
script.

To get their user names, i am using <% =Session("UID") %>, which gives me
their user id from the login page. Currently its for 30 employees, and I
have a database with their information. So I have a text box Associate_Name
which autopopulates by using <% =Session("UID") %>. Now depending upon
Associate_Name, I want it to autopopulate the employee number, and the phone
number.

Then this form will submit the information to the database.

Thanks,

Shikha


Trevor L. said:
shikha said:
Hello,

First of all the help I got from this site, MVPs are just amazing :)
:)...don't know what I would have done without you guys :)

I have a question...On my site, employees login, stores the cookie,
then it takes them to the main page... On main page, it shows their
name (Text box), depending upon the employee name, it should
autopopulate 2 other text boxes with their employee number and
telephone#. How can I do that?

When you say "should", do you mean that you have written code which fails, or that this is what you want it to do.

In either case, you need some Javascript to pick up their names and alter the fields. You may even need a database to store these
details if there are a large number of employees.
Looked for lot of help, but all the help was for combo boxes or drop
down, but in this case I have a text box, and its value determines
the value in two other textboxes.

Any help will be greatly appreciated.

Please post back with the URL or, if it is on intranet, the code (or at least the relevant part of it).
--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
T

Trevor L.

shikha said:
Trevor,

actually i figured it out.. I used java script with if else
statement. This way i had to enter information for all the
employees...but atleast it works.

Thank you for looking into this!!!

shikha

Hi, shikha,
I guess you are saying you wrote an if... else... with 30 levels
if (userid == '1234') empl_num= '234'
else
if (userid == '1456') empl_num= '678'
etc.
and the same for phone number

That would certainly work, but isn't this information on the database?
If you can get the user name by <% =Session("UID") %>, can't you also get the employee number and phone number by a similar method?

Anyway there are other ways to make the javascript simpler.
1. Use the switch statement
==================
switch (userid)
{
case '1234':
{empl_num= '234';
phone_num ='555-1234';
break }
case '1456':
{ empl_num= '678';
phone_num ='555-2678';
break }
.....
default:
}

2. Use the unary if else
===============
empl_num = (userid == '1234') ? '234'
: (userid == '1456') ? '678'
..........
: '999999'
and similarly for phone_num
Both 1. and 2. have the advantage that once the userid is found it does not search the rest of the userids.

3. Store the 3 items in arrays
===================
useridarr = new Array
('1234','1456', ...)
empnumarr = new Array
('234','678', ....)
phonumarr = new Array
('555-1234','555-2678', ....)

You could then search useridarr for the value , e.g. '1456', then use the array index (in this case, 1) to retrieve the
corresponding value from empnumarr
So if the value '1456' is in the variable userid
for (i=0; i < useridarr.length ; i++)
{
if (useridarr == userid)
{empl_num = empnumarr ; break}
}
and similarly for phone_num
This also has have the advantage that once the userid is found it does not search the rest of the userids, but means that the arrays
must be kept in synch.

One could also do this
numbarr = new Array
('1234', '234', '555-1234',
'1456', '678', '555-2678',
.....)
So if the value '1456' is in the variable userid
for (i=0; i < numbarr.length ; i = i+3)
{
if (numbarr == userid)
{ empl_num = numbarr [i+1] ;
phone_num = numbarr [i+2] ;
break }
}
This makes it easier to keep the numbers in synch as each line in the array must have 3 numbers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top