struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Au-Yeung, Stella H" <stella.au-ye...@eds.com>
Subject RE: Can a <a href> be made to function as a 'submit'
Date Wed, 25 Feb 2004 18:27:06 GMT
Thanks Nick...I completelu forgot you can 'dynamically' change form fields
value such as 'document.myForm.partIdx.value'.  What you suggested should
work.  

-----Original Message-----
From: Nick Heudecker [mailto:nick@systemmobile.com] 
Sent: Wednesday, February 25, 2004 12:11 PM
To: Struts Users Mailing List
Subject: Re: Can a <a href> be made to function as a 'submit'


Assuming I know what you're talking about, this is also pretty easy to
address:

The form is hidden, with one hidden field.  It doesn't have to be hidden,
certainly. <form name="myForm"> <input type="hidden" name="partIdx"/>
</form>

The link calls the JavaScript function, passing in the current parameter. <a
href="javascript:submitForm('<%=index%>');">Click</a>

The function will set the value of the form field and call submit. <script
language="JavaScript"> function submitForm(indexVal) {
  document.myForm.partIdx.value = indexVal;
  document.myForm.submit();
}
</script>

On 2004-Feb-25 11:02, Au-Yeung, Stella H wrote:
> But each of my <a href> is within a <html:iterate indexId="index"  
> .....> tag and it passes the index to the next page base on which item in
the list
> the user clicks.   How can I do that with what you suggested?
> 
> My current <a href>:
> <a href="app/Order/DisplayPictureRequest.exec?partIdx=<%=index%>">
>           <img src="images/icoClick.gif"></a>&nbsp;
> 
> Thanks!
> 
> -----Original Message-----
> From: Nick Heudecker [mailto:nick@systemmobile.com]
> Sent: Wednesday, February 25, 2004 10:45 AM
> To: Struts Users Mailing List
> Subject: Re: Can a <a href> be made to function as a 'submit'
> 
> 
> 
> Sure, all you need is a bit of JavaScript that submits your form tag. 
> The 'myForm' form is representative:
> 
> <form name="myForm">
> <input type="text" name="someField1"/>
> <input type="text" name="someField2"/>
> </form>
> 
> <a href="javascript:submitForm();">Click</a>
> 
> And finally, the function:
> 
> <script language="JavaScript">
> function submitForm() {
>   document.myForm.submit();
> }
> </script>
> 
> That should do it.
> 
> 
> 
> On 2004-Feb-25 10:02, Au-Yeung, Stella H wrote:
> > Hi:
> > Can a <a href> be made to function as a 'submit' and upon 
> > submission,
> > all the formBean properties are remembered in the Action class that 
> > handles it. When  I try to use just the <a href> I can't get the
formBean
> properties to
> > be remembered.   But I can't change my list of <a href> as submit
buttons
> > because I need to pass arguments on each of the <a href>. Here's an 
> > example of what I try to do on my JSP page: When the user clicks a 
> > link to see a picture of an item, this JSP will be replaced by 
> > another JSP with the picture.  So before I leave this page, I "must" 
> > save the Personal information and the item list in a temporary 
> > location so when I return to this page, those values will be 
> > repopulated. But my problem is, clicking the <a href> link will not
carry over he
> > formBean properties to the Action class for me to save.   'Submit' will
> but
> > I can't change those <a href> to 'submit' because I need to pass the 
> > item index (0,1,2 etc.) through each <a href> to the Action class.
> > 
> > Personal information:
> > First Name:		Last Name:		Mailing Address:
> > 
> > 
> > List of items in your shopping cart:
> > ABC tennis racket	1	<a href> link to see a picture and pass the
> > index of this item to the Action class
> > Wilson tennis ball	5	<a href> link to see a picture and pass the
> > index of this item to he Action class
> > XYZ tenis shirt		2          <a href> link to see a picture
> and pass
> > the index of this item to he Action class
> >  
> > I appreciate any suggestion.
> > 
> > 
> > 
> > 
> > 
> > --------------------------------------------------------------------
> > -
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> --
> Nick Heudecker
> System Mobile, Inc.
> Email: nick@systemmobile.com
> Web: http://www.systemmobile.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

-- 
Nick Heudecker
System Mobile, Inc.
Email: nick@systemmobile.com
Web: http://www.systemmobile.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message