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

Calling two procedures Using Onclick

Status
Not open for further replies.

tripp2222

Technical User
Nov 30, 2004
32
US
Can someone please tell me if it is possible to call two procedures using OnClick and if so can you show me the syntax. I have a drop-down box that need to call two procedures. Thanks for the help in advance. Below is what I have so far in order to call the one procedure already created.
<select size="1" name="MIFGroup" onclick="PopulateDepartments(MIFGroup)" tabindex="1">
 
I am now receiving the expected end of statement did I code the line correctly.

Code:
<select size="1" name="MIFGroup; MIFLocation;" onclick="PopulateDepartments(MIFGroup); PopulateLocation(MIFLocation);" tabindex="1">
 
I would suspect it has something to do with trying to use two names for the select box. Why do you need to refer to it as both MIFGroup and MIFLocation?
Let me know what exactly the functions are supposed to do and I will try and help.

Cheers,
Nick

Nick (Webmaster)

 
HowardMarks is right, you can't have

Code:
name="MIFGroup; MIFLocation;"
 
The two functions when called populate two separate drop-down boxes from a database. The functions are called when the first drop-down box is clicked. Everything works correctly meaning the drop-down boxes populate if I call the functions separtely, but I can't get it to work calling both functions.

Code:
	<tr><td colspan="5">Submit Computer Information to Access Inventory</td></tr>
      <tr valign="top">
      <td  align="Left">Department:</td>
      <td  align="Left">Select Department Group<br>
	   <select size="1" name="MIFGroup; MIFLocation;" onclick="PopulateDepartments(MIFGroup); PopulateLocation(MIFLocation);" tabindex="1">
      <option value="1">SD</option>
      <option value="2">HS</option>
      <option value="3">SCBN/FS</option>
      <option value="4">SGSC</option>
      </select>
      </td>
      <td  align="Left"colspan= "3">Select Department:<br>
      <select size="1" width="40" name="DepartmentName" tabindex="2">
      <script language="VBScript">
			Sub PopulateDepartments(MIFGroup)
				Set dbInventory = CreateObject("ADODB.Connection") 
				Dim strConnectionString
				Const strDataSource = "\\ssweb\inventory\inventory.mdb" 
				strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&strDataSource&";"
				dbInventory.Open strConnectionString
				For Each objOption In DepartmentName.Options
					objOption.RemoveNode
				Next 				
				Set rstOptions = CreateObject("ADODB.Recordset") 
			Select Case MIFGroup.value
				Case "1" 'SD Group
					strSQL = "SELECT * FROM tblDepartmentLookup WHERE DepartmentShortName = 'IS' OR DepartmentShortName = 'Law' OR DepartmentShortName = 'HR' OR DepartmentShortName = 'GO' OR DepartmentShortName = 'Finance'OR DepartmentShortName = 'SU'" 
				Case "2" 'HS Group
					strSQL = "SELECT * FROM tblDepartmentLookup WHERE DepartmentShortName = 'HS' OR DepartmentShortName = 'Call Center'" 
				Case "3" 'FS Group
					strSQL = "SELECT * FROM tblDepartmentLookup WHERE DepartmentShortName = 'Food Service' OR DepartmentShortName = 'SCB' OR DepartmentShortName = 'STG'" 
				Case "4" 'Plant Group
					strSQL = "SELECT * FROM tblDepartmentLookup WHERE DepartmentShortName = 'SGSC'" 
			End Select 'PopulateDepartments
			rstOptions.Open strSQL, dbInventory
			Set objDepartmentName = rstOptions("DepartmentLongName") 
			Set objDepartmentID = rstOptions("idDepartment") 
			Do While Not rstOptions.EOF
				Set objOption = Document.createElement("OPTION")
				objOption.Text = objDepartmentName & " (" & objDepartmentID & ")"
				objOption.Value = objDepartmentID
				DepartmentName.Add(objOption)
				rstOptions.movenext
			Loop
			dbInventory.close
		End Sub
			</script>
      </select>
      </td>
      <td align="left">Location:<br>
		<select size="1" width="40" name="LocationName" tabindex="1">
      <script language="VBScript">
			Sub PopulateLocation(MIFLocation)
				Set dbInventory = CreateObject("ADODB.Connection") 
				Dim strConnectionString
				Const strDataSource = "\\ssweb\inventory\inventory.mdb" 
				strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&strDataSource&";"
				dbInventory.Open strConnectionString
				For Each objOption In LocationName.Options
					objOption.RemoveNode
				Next 				
				Set rstOptions = CreateObject("ADODB.Recordset") 
			Select Case MIFLocation.value
				Case "1" 'SD Group
					strSQL = "SELECT * FROM tblLocationLookup WHERE LocationShortName = 'pop'"
				   Case "2" 'HS Group
					strSQL = "SELECT * FROM tblLocationLookup WHERE LocationShortName = 'pop' "
				Case "3" 'FS Group
					strSQL = "SELECT * FROM tblLocationLookup WHERE LocationShortName = 'pop' "
				Case "4" 'Plant Group
					strSQL = "SELECT * FROM tblLocationLookup WHERE LocationShortName = 'pop' "
			End Select 'PopulateLocation
			rstOptions.Open strSQL, dbInventory
			Set objLocationName = rstOptions("LocationLongName") 
			Set objLocationID = rstOptions("idLocation") 
			Do While Not rstOptions.EOF
				Set objOption = Document.createElement("OPTION")
				objOption.Text = objLocationName & " (" & objLocationID & ")"
				objOption.Value = objLocationID
				LocationName.Add(objOption)
				rstOptions.movenext
			Loop
			dbInventory.close
		End Sub
			</script>
      </select>
		</tr>
 
After seeing your code I think you need to move this to the forum329 vbscript forum

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
HowardMarks is right, [!]you can't have[/!]

name="MIFGroup; MIFLocation;"

I tested this and was wrong, I guess you can have it, but it's terrible practice.
 
How do I get away from receiving the error message "object required" without using name=
 
I was referring to naming 2 different things. I'm not very good at VBScript, but just name that select box one thing like:

Code:
name="MIFSelect"

In your onclick handler, just send the reference of that object to both subroutines.

I don't know how to do that, as it is more for the VBScript
forum.
 
Thanks monksnake. That did it. I feel stupid it was that darn easy. WOW.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top