Urgent: Multiple buttons in form

Results 1 to 2 of 2

Thread: Urgent: Multiple buttons in form

  1. #1
    Prabal Dhar Guest

    Default Urgent: Multiple buttons in form

    I am new to ASP.Can someone help me with this tricky issue.I have form with multiple buttons.I require that when the user clicks on a button the corresponding function should be executed in the server side. I cannot make it work with OnClick. I tried the concept of pageObjects which also did not work.I will be very grateful if someone can tell me how to map button to a function to be executed in the server side.<BR>thanks in advance,<BR>Prabal

  2. #2
    Join Date
    Dec 1969
    Posts
    1,019

    Default RE: Urgent: Multiple buttons in form

    The onclick can work, just pass an identifying value to a hidden field via JavaScript or to the action as a querystring:<BR>pg1 has 3 buttons, pg2 runs the server side function<BR><BR>pg1.asp:<BR>&#060;form name="myform" method="post" action="pg2.asp"&#062;<BR>&#060;input type="button" value="function1" onClick="myFunc(&#039 1&#039)"&#062;<BR>&#060;input type="button" value="function2" onClick="myFunc(&#039 2&#039)"&#062;<BR>&#060;input type="button" value="function3" onClick="myFunc(&#039 3&#039)"&#062;<BR>&#060;input type="hidden" name="myval"&#062;<BR>&#060;/form&#062;<BR>And, in the &#060;head&#062;:<BR>&#060;script language="JavaScript"&#062;<BR> function myFunc(q) {<BR> document.myform.myval=q<BR> document.myform.submit()<BR> }<BR>&#060;/script&#062;<BR><BR>And, on pg2.asp<BR>&#060;%<BR> select case request.form("myval")<BR> case 1<BR>&#039 put your server side function here<BR> case 2<BR>&#039 function 2<BR> case 3<BR>&#039 function 3<BR> end select<BR>%&#062;<BR>You can also do it with the action of the form & querystrings, basically the same idea.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •