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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning a key value from a listbox

Status
Not open for further replies.

luckydata

Programmer
Sep 15, 2002
10
0
0
AU
Hi,
I am very new to Java Script and are desparate for advice. I am developing a large application in ASP.net using Visual Studio. The Users love selecting data from list boxes. In one instance I have successfully followed Tek-Tips faq 333-3656 "Linked list boxes without reloading the page", without forms submission. Its fast and works great. But I have two more to go.

The second one requires selecting a sentence and returning an integer, "SQLid" - the record id will be used in subsequent processing. The table requires three columns which I have called "DisplayGroup", "InstText" and "SqlID". Display group is displayed in the first text box and is the criterium on which the InstText is displayed in the second listbox. Using the terms of Visual Studio, InstText has to be the DataTextField and SqlID has to be the DataValue Field. But I want to do it on the client. I was not able to find any example of displaying text and returning a different value on the client. Is this possible? Can you point me in the right direction of an example.

My script does not work of course and I nead a few answers.
The resulting function sent to the client is 6.3k. Is there some limit to the size of a Java script function?
Is it practical to have an array of this size on the client? The size will be static.
Regardles of the practicalities, you might appreciate that it is a challenge to make it work - even if I have to discard it. The script looks perfect, but causes an IE script error - Line 36, Char 10, Error Expected '(', code 0. It expected a LH bracket after mamy lines of script. If it requested a RH bracket at least I could look for a LH bracket. I can't identify line numbers either. I would appreciate any suggestion on how to locate the problem.

 
Thanks for your interest Dan,
As I said previously, I am a novice at Java script. I realy need to know if there is a limit to the length of a script, and if I can display text and return another value in a list box on the client.

This is a cut down version of the function which is executed on the client. I have edited it from a continuous string, so that the three columns of the array (DisplayGroup, InstText and SqlID) recognisable in the structure.

<script language="JavaScript">
var IL;
function init()
{IL = {InstList: [
{DisplayGroup: "General (Vic)",
InstText:["The instructions given in MPD Explosives Handling,
Storage and Transport Policies (DSTO-GD-0234) must be
observed, together with any additional instructions given
below or posted.",
"In the event of fire, raise the alarm and evacuate the
facility immediately."],
SqlID:["39",
"23"]},
{DisplayGroup: "General",
InstText:["The instructions given in the WSD Explosives Manual
must be observed, together with any additional instructions
given below or posted.",
"Any untoward incident must be reported immediately to the
OIC, Head of Group and the Explosives Safety Officer",
"Unless authorised by the ESO or Chair ExSAP, all
explosives work is to cease when electrical storm activity
is imminent.",
"In the event of fire, raise the alarm and evacuate the
facility immediately."],
SqlID:["38",
"5",
"42",
"24"]},
{DisplayGroup: "Waste Bins",
InstText:["* Waste solvent contaminated with explosives.",
"* Special waste solvent.",
"* Fired cartridge cases.",
"* Unfired cartridge cases."],
SqlID:["57",
"58",
"59",
"60"]},
{DisplayGroup: "Chemical Safety",
InstText:["Chemicals must be clearly and correctly labelled",
"Operations of a hazardous nature must be conducted in the
fume cupboard.",
"Solvents not in use must be kept in the flammable solvents
cupboard.",
"MSDS are available via the Chemwatch database on networked
computers",
"Chemical Spill-kit is located in Bay 4, 126"],
SqlID:["12",
"31",
"34",
"61",
"63"]}
]}}
</script>
 

The code you've given above doesn't error 9after I remvoe the line breaks), so can only assume that your JS error lies elsewhere in code you haven't posted.

As far as I know, there is no limit to the size a JS function can be.

Hope this helps,
Dan
 
Thanks for your concern.
After eight days of torment, a doctors visit and a bottle of sleeping pills I found the answer and made it work. I have posted it under FAQs because it is complex. It is also reflects my novice understanding of Java Script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top