Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JAVA Lookup

Status
Not open for further replies.

Scooby62

MIS
Jul 10, 2002
97
CA
Hi There.

I've got a situation where a user is enroling in a certain course on a certain date. They are making their selections via a drop down (combo box) provided via a java script program (eg., <option value=1>April 14</option>). The combo box is working perfectly and only shows the text April 14 and not the value. This is perfect.

The problem occurs when we complete the transaction by presenting the user with a confirmation form which details the date, course, their name, etc.). It is pulling back the value 1 and not the text string April 14.

So the question is how do we get it to pull the text string from a database field that is storing the value? What is the code. Currently it reads: <p>Course Information no.:&nbsp;&nbsp;<!--webbot bot="ConfirmationField" S-Field="firstChoice" -->.

I would like the S-Field to go back to the combo box definition and look up a '1' as being April 14.

Can this be done?

Many thanks.
 
Why, if you are trying to set a date, are you using a numeric value? Why not use
Code:
<option value='April 14'>April 14</option>
If you are intent on using numeric values rather than dates, you will have to carry out some form of cross-reference to convert your numeric value back into a date - i.e. 1=April 14

This could be done via another table in your database or by hard-coding the equivalences into the page which retrieves the database record. Either way is messy - I recommend writing date values in the first instance.
 
Thank you but another problem is that there may be more than one course on April 14th. That's why we've used 1, 2, 3, etc.

 
I therefore assume that you have another database table which cross-references the Course Number (1,2,3...etc.) with the Course Date (14th April etc.)???

Therefore, when you populate the confirmation form, you need to retrieve the date from this table based on the Course Number originally saved.
 
Well, for efficiency I wanted to have to code in one place and have it used by several aspects of the program in order to keep maintenance low. Now I guess I'll have to change it in two places when dates change or I could program 365 days in both places and never have to change it.

Thanks everyone for your help.
 
Efficiency rules that you indeed store it in one place so that updates are easy and you don't ever "get out of sync".

For this reason, you should at least consider storing the course name (or id reference) and start date in a seperate table of the database. You can then pick it up server-side when building up the page html... and when you need to change the course details... you change it in the database (it's data... you change the data... not the source code to your page).

Sorry to rant.

Jeff
 
BabyJeffy.

Yes I totally agree. My first objective is always to be efficient with code.

You've reinforced my thoughts.

Thanks again to everyone, you know you guys rock.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top