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

How to submit to the current form?

Status
Not open for further replies.
Oct 11, 2006
300
US
Hi,

I have an onClick event for the radio buttons associated for each employee.


Code:
<input type="radio" name="empid" id="empid40801" value="40801" onClick="submitEmpID(this);">

Javascript is:


Code:
function submitEmpID(el) {
	var f = el.form;
	for(var i=0; i<f.empid.length; i++)
	{
		if( f.empid[i].checked )
		{
			//alert(f.empid[i].value);
			f.Emp_ID.value = f.empid[i].value;
			f.submit();
		}
	}
}
What I am doing is submitting the employee id on click of the radio button associated with that employee, then populating a hidden text box with that employee ID.

Based on the textbox value, I feed that value to the SQL statement to generate another list of reports that the employee is eligible to see.

My question is:

How can submit to the current form? My form tag has:


Code:
<form name="f" id="f" action="ViewReport4.asp" onSubmit="form_Validate(this);">

When I click on the employee radio button in such a way that I submit to my current form, select other form elements, then click on the submit button where the page is being submitted to ViewReports.asp without the current form being validated.

Is that possible?

Thanks.
 
not sure i understand...

you are submitting the form when you click the radio button. is it the same form named "f"? if so, what is it you want to accomplish? why are you submitting the form twice?



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
OK. Let me explain further.

I have an hierarchy of organization on my left hand side. Every employee have different set of reports to view. So my onclick of the radio buttons beside the employee listing will submit the value of the radio button(empid) to the SQL query:

I know this is not a VBScript forum, but I want to give you an idea of what I am trying to do.
Code:
strEmp_ID = request("Emp_ID")
	If strEmp_ID = "" Then
		strEmp_ID = strEmpID
	End If

	Dim rsPlan
	Set rsPlan = Server.CreateObject("ADODB.Recordset")

	Dim planSQL
	planSQL = "SELECT DISTINCT Report.PlanSetup, Report.Report, AMP.EmpID, AMP.DateOfPost " & _
	          "FROM Report INNER JOIN " & _
	          "PlanSetup ON Report.PlanSetup = PlanSetup.UniqueIdentifier INNER JOIN " & _
	          "AMP ON PlanSetup.DisplayName = AMP.PlanSetup " & _
	          "WHERE AMP.EmpID = " & strEmp_ID & " AND " & _
	          "AMP.DateOfPost IN (SELECT MAX(DateOfPost) FROM AMP WHERE EmpID = " & strEmp_ID & ") "

My onclick event submit the radio button value to the hidden text box which is in turn grabbed by this SQL query to build the list of reports for that selected reports. But when I have do that submit. it goes to the next page.

I do not want to go the next page because the employee should select his own report and the respective form elements to see the report.

It looks like I need to segregate the page into 2 frames with invisible borders (which I never liked) where the organization page submits to the reports form.

Or make 2 forms within the same page where one form submits to the 2nd form. And then the 2nd form submits to the 2nd page which shows the reports.

Any suggestions.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top