Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

JSP Form Problem Input text box

  • 24-05-2007 11:04am
    #1
    Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭


    Ive 2 forms on the one page.

    A userAddress string is inputted via a textbox on the first form.

    There is a input hidden field in the second form that needs to retrieve the string inputted in the text box on the first form into its value.

    Can this be done?

    Heres some code that shows my problem
    <%
    String userAddress = (null == (userAddress = (String)request.getAttribute("useraddress")) ? "" : userAddress);
     
    %>
     
    <form action="/servPublicArea" method="POST" name="form1" onsubmit="return checkFields();">
    <div id="email">
    		 <input type="text" name="email" value="<%=userAddress%>" size="50">
    	</div>
     
    <div id="release">
    		<input id="submitButton" name="submit" type="submit" value="Release Mail" onclick="this.enabled = false; return true;">
    		       
    		
    	</div>
    </form>
     
    <form action="/servPublicArea" method="POST" name="whitelistform" onsubmit="return checkFields();"> 
    	<input type="hidden" name="view" value="whitelistandrelease">
    	<input type="hidden" name="emailwhitelist" value="<%=userAddress%>">
     
    <div id="release">
    		<br>
    		<input id="submitButton2" name="submit2" type="submit" value="Release Mail and Whitelist Sender" onclick="this.enabled = false; return true;">
    		
    	</div>
     
    </form>
    


Comments

  • Registered Users, Registered Users 2 Posts: 7,990 ✭✭✭Trampas


    Why have you two forms on the one page?


  • Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭quinnd6


    Because Ive 2 buttons performing different actions so I think they need to be in different forms


  • Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭quinnd6


    Maybe Id just be better off having both submit buttons in the same form.

    How do I detect which button is pressed?


  • Moderators, Science, Health & Environment Moderators Posts: 10,088 Mod ✭✭✭✭marco_polo


    quinnd6 wrote:
    Maybe Id just be better off having both submit buttons in the same form.

    How do I detect which button is pressed?

    Regular <input type=submit name="" value=""> buttons put a name=value pair in the query string that has the name of the button and the button text as its value.

    Looking up the parameter will tell you if the button was pressed or not. If getParameter("button1") is null then you know button 1 was not pressed etc.

    If you wanted the buttons to go to different pages then I think you would have to use javascript to achieve this.


  • Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭quinnd6


    Is there something wrong with this?

    <%if(request.getParameter("submitButton")!=null){%>
    <input type="hidden" name="view" value="spamrel">
    <% } %>


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,240 ✭✭✭hussey


    A userAddress string is inputted via a textbox on the first form.

    There is a input hidden field in the second form that needs to retrieve the string inputted in the text box on the first form into its value.

    Can this be done?

    easist way is through JS - on your 2nd form, have a method when the user submits the form, copy the Form1.field.value to the Form2.hiddenfield.value etc

    I think the JS is : document.[FormName].[fieldname].value

    ************
    Is there something wrong with this?

    <%if(request.getParameter("submitButton")!=null){%>
    <input type="hidden" name="view" value="spamrel">
    <% } %>
    No - but only if you are posting a form to the jsp


Advertisement