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

Using HREF value for form procedure 1

Status
Not open for further replies.

rmagan

Programmer
Jun 3, 2003
35
US
I have a form that uses links in a table to execute the submit. The submit calls a procedure that needs to be passed the value of the link. I think I need to use the onSubmit to populate a hiiden input field with the value of the link. How do you set a hidden field the value of the link?


<html>
<form name=&quot;add_class_to_schedule&quot; onSubmit=&quot;fillFields2(this)&quot; action=&quot;stars3.star_portal.add_class_to_schedule&quot; method=&quot;post&quot;>
<table border=&quot;0&quot; cellspacing=0 cellpadding=2 id=&quot;class_mast&quot;>
<thead>
<tr>
<th BGCOLOR=&quot;#000063&quot; nowrap align=&quot;left&quot;><font CLASS=&quot;PortletText1&quot; COLOR=&quot;WHITE&quot;>Class-Sec</font></th>
</tr>
</thead
<TBODY>
<tr>
<td><a href=&quot;javascript:void(document.add_class_to_schedule.submit())&quot;>109-001</a></td>
</tr>
<tr BGCOLOR=#BBBBBB>
<td><a href=&quot;javascript:void(document.add_class_to_schedule.submit())&quot;>109-002</a></td>
</tr>
<tr>
<td><a href=&quot;javascript:void(document.add_class_to_schedule.submit())&quot;>109-004</a></td>
</tr>
<tr><td ALIGN=&quot;CENTER&quot;><input type=&quot;hidden&quot; name=&quot;p_action&quot; value=&quot;Submit&quot;>
</table>
</form>
</body></html>
 
something like

<a href=&quot;javascript:document.add_class_to_schedule.p_action.value=this.value;void(document.add_class_to_schedule.submit())&quot;>
 
rmagan,

Try this:

Code:
<html>
<head>
<script language=&quot;javascript&quot;>
<!--
	function submitLink(hrefValue)
	{
		document.forms['add_class_to_schedule'].p_action.value = hrefValue;
		document.forms['add_class_to_schedule'].submit();
	}
//-->
</script>
</head>

<body>
<form name=&quot;add_class_to_schedule&quot; onSubmit=&quot;fillFields2(this)&quot; action=&quot;stars3.star_portal.add_class_to_schedule&quot; method=&quot;post&quot;>
<table border=&quot;0&quot; cellspacing=0 cellpadding=2 id=&quot;class_mast&quot;>
<thead>
	<tr>
		<th BGCOLOR=&quot;#000063&quot; nowrap align=&quot;left&quot;><font CLASS=&quot;PortletText1&quot; COLOR=&quot;WHITE&quot;>Class-Sec</font></th>
	</tr>
</thead>
<tbody>
	<tr><td><a id=&quot;abc&quot; href=&quot;javascript:submitLink('109-001');&quot;>109-001</a></td></tr>
	<tr BGCOLOR=#BBBBBB><td><a href=&quot;javascript:submitLink('109-002');&quot;>109-002</a></td></tr>
	<tr><td><a href=&quot;javascript:submitLink('109-004');&quot;>109-004</a></td></tr>
	<tr><td ALIGN=&quot;CENTER&quot;><input type=&quot;hidden&quot; name=&quot;p_action&quot; value=&quot;&quot;></td></tr>
</tbody>
</table>
</form>
</body>
</html>

I realise that you have to repeat the text contained inbetween the open and close A tags, but for some reason, IE doesn't want to recognise &quot;this.innerHTML&quot;, etc for me...

Hope this helps!
Dan

 
Hmmm..

If you use my code, you'd probably also want to remove the onSubmit declaration from the form tag... Didn't spot that one until afterwards ;o)

Dan
 
BillyRay,

We really need to take turns - I'm sure we keep answering the same questions in the same way !!

;-)

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top