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!

Passing values in a form on an ASP page

Status
Not open for further replies.

cmitsys

Technical User
Oct 31, 2003
14
0
0
Hi, I have a from on an ASP page that I am having problems with. What I need to do is have the action link contain the values that were entered into the form - for example...

Code:
<form action=&quot;[URL unfurl="true"]http://dot0dta1asodev5.mdot.w2k.state.me.us:7778/devmats/reports.salt_usage?crew=<%=[/URL] crew %>&mtrl=1&quot; method=&quot;post&quot; name=&quot;mtrl_usage&quot; id=&quot;mtrl_usage&quot;> 
        <table width=&quot;50%&quot;  border=&quot;0&quot; cellspacing=&quot;5&quot; cellpadding=&quot;0&quot;> 
          <tr valign=&quot;top&quot;> 
            <td width=&quot;27%&quot; nowrap><div align=&quot;right&quot;><strong>4 digit Crew Number: </strong></div></td> 
            <td width=&quot;3%&quot; nowrap><strong>   </strong></td> 
            <td width=&quot;14%&quot; nowrap><input name=&quot;crew&quot; type=&quot;text&quot; id=&quot;crew&quot; size=&quot;10&quot; maxlength=&quot;4&quot;> </td> 
            <td width=&quot;56%&quot; nowrap><div align=&quot;right&quot;><em><strong>Example:</strong></em> Division 1 = 1000<br> 
                District 13 = 1300<br> 
                Crew 1321 = 1321 </div></td> 
          </tr> 
          <tr valign=&quot;top&quot;> 
            <td nowrap><div align=&quot;right&quot;><strong>Material: </strong></div></td> 
            <td nowrap> </td> 
            <td colspan=&quot;2&quot; nowrap><select name=&quot;material&quot; id=&quot;material&quot;> 
                <%
While (NOT rsMtrl.EOF)
%> 
                <option value=&quot;<%=(rsMtrl.Fields.Item(&quot;MATL_SYS_ID&quot;).Value)%>&quot;><%=(rsMtrl.Fields.Item(&quot;DESCR&quot;).Value)%></option> 
                <%
  rsMtrl.MoveNext()
Wend
If (rsMtrl.CursorType > 0) Then
  rsMtrl.MoveFirst
Else
  rsMtrl.Requery
End If
%> 
              </select></td> 
          </tr> 
          <tr valign=&quot;top&quot;> 
            <td colspan=&quot;4&quot; nowrap><div align=&quot;center&quot;> 
                <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;> 
    
                <input type=&quot;reset&quot; name=&quot;Submit2&quot; value=&quot;Reset&quot;> 
              </div></td> 
          </tr> 
        </table> 
      </form>

As you can see the action element will have dynamic values, so far this has not worked for me. I have read a few things on passing values from one form to the next, but they seem to depend on the second page requesting these values, I am passing this to an Oracle Database Procedure. So the requesting page will not work.

How do I put the values entered into the form into the action element?

OR

Do you know of another way to do this without the user having to click more than the 1 submit button?

FYI: If you read the code you will see only the crew is dynamic in this example, the mtrl (materials) will be using the same method to make it dynamic also.

Thnx in advance!
 
YOu can't do it that way - you need to pass the form back to the server and have your form handler call whatever page/function/procedure you need...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Hi, how should I do that then - I am not a programmer so your assistance and time is truely appreciated by me.

If you could show me what action string I should have and how i tell the form handler where to send the selected values that would be great.

or an example would be better, not that I expect you to write the code for me, but then I will understand you post better.

Thank you!
 
i use &quot;dynamic&quot; action urls all the time ... however, your example is trying to use a variable which hasn't been set yet. For example:

<form action=&quot;action.asp?id=<%=request(&quot;id&quot;)%>

the &quot;id&quot; variable would have had to already been passed to this page and set from a previous link.

If you click a link &quot;gohere.asp?id=4&quot; and then it takes you to your form, it will work perfectly. However, you can't use a dynamic variable before the variable is set.
 
I managed to get it to work by doing so...

Code:
<form action=&quot;[URL unfurl="true"]http://mdotweb<%=[/URL] Request.ServerVariables(&quot;PATH_INFO&quot;) %>?action=validate&quot; method=&quot;post&quot; name=&quot;mtrl_usage&quot; id=&quot;mtrl_usage&quot;> 
<table width=&quot;50%&quot;  border=&quot;0&quot; cellspacing=&quot;5&quot; cellpadding=&quot;0&quot;> 
  <tr valign=&quot;top&quot;> 
	<td width=&quot;27%&quot; nowrap><div align=&quot;right&quot;><strong>4 digit Crew Number: </strong></div></td> 
	<td width=&quot;3%&quot; nowrap><strong>   </strong></td> 
	<td width=&quot;14%&quot; nowrap><input name=&quot;crew&quot; type=&quot;text&quot; id=&quot;crew&quot; value=&quot;<%= Request.Form(&quot;crew&quot;) %>&quot; size=&quot;10&quot; maxlength=&quot;4&quot;> </td> 
	<td width=&quot;56%&quot; nowrap><div align=&quot;right&quot;><em><strong>Example:</strong></em> Division 1 = 1000<br> 
		District 13 = 1300<br> 
		Crew 1321 = 1321 </div></td> 
  </tr> 
  <tr valign=&quot;top&quot;> 
	<td nowrap><div align=&quot;right&quot;><strong>Material: </strong></div></td> 
	<td nowrap> </td> 
	<td colspan=&quot;2&quot; nowrap><select name=&quot;mtrl&quot; id=&quot;mtrl&quot;> 
		<%
While (NOT rsMtrl.EOF)
%> 
		<option value=&quot;<%=(rsMtrl.Fields.Item(&quot;MATL_SYS_ID&quot;).Value)%>&quot;><%=(rsMtrl.Fields.Item(&quot;DESCR&quot;).Value)%></option> 
		<%
rsMtrl.MoveNext()
Wend
If (rsMtrl.CursorType > 0) Then
rsMtrl.MoveFirst
Else
rsMtrl.Requery
End If
%> 
	  </select></td> 
  </tr> 
  <tr valign=&quot;top&quot;> 
	<td colspan=&quot;4&quot; nowrap><div align=&quot;center&quot;> <br> 
		<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;> 
	  </div></td> 
  </tr> 
</table> 
</form>

I then have the following code at the top of the page...

Code:
<%
ErrMsg = &quot;&quot;
If Request.QueryString(&quot;action&quot;) = &quot;&quot; Then
	'
	' Show the form - the form has not yet been submitted
	'
Else
	If Request.Form(&quot;crew&quot;) = &quot;&quot; Then
		'
		' No crew number was supplied
		'
		ErrMsg = &quot;<font color=RED><b>ERR001: No crew number was entered</b></font>&quot;
	ElseIf IsNumeric(Request.Form(&quot;crew&quot;)) = False Then
		'
		' Crew number supplied was Not A Number (NaN)
		'
		ErrMsg = &quot;<font color=RED><b>ERR002: Crew number can be numbers only</b></font>&quot;
'	ElseIf Len(Request.Form(&quot;crew&quot;) <> 4) Then
'		'
'		' Crew number was <> 4 numbers
'		'
'		ErrMsg = &quot;<font color=RED><b>ERR003: Crew number must be 4 digits</b></font>&quot;
	Else
		'
		' Send values to Oracle - the form has been completed and then submitted
		'
		Response.Redirect(&quot;[URL unfurl="true"]http://dot0dta1asodev5.mdot.w2k.state.me.us:7778/devmats/reports.salt_usage?crew=&quot;[/URL] & Request.Form(&quot;crew&quot;) & &quot;&mtrl=&quot; & Request.Form(&quot;mtrl&quot;))
	End If
End If
%>

This then checks to see if there is any value in the action container, if the value = &quot;&quot; then it shows the form otherwise it validates the entries.

But... the Error checking (validation) is having problems. If I have ErrMsg002 and ErrMsg003 in the code the validation does not work correctly, if I comment out either one then the form works correctly.

Any ideas?

Also would I be better putting the error codes into an Array? - If so how do I do this?

Thank you for all your help Folks!
 
I was meaning to add - This has thus created the Dynamic URL that I needed, the values are now passed to the Orcale Procedures as required, but I am still having problems with the error codes and would appreciate anyones time to help figure the problem.
 
Seems ok like it is....Does this help?

ElseIf IsNumeric(Request.Form(&quot;crew&quot;)) = False Then

ElseIf NOT IsNumeric(Request.Form(&quot;crew&quot;)) Then



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top