473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How to pass 2 parameters with OnClick?

Hello,

Here is my problem:
I am displaying to a user a row of buttons. Depending on which button
user presses, I want to go to a different URL and to give a different
value to a hidden variable.

My code is:
<FORM NAME=FORM1 ACTION="">
<input type="button" name="B1" onclick="ModC('1')">
<input type="button" name="B2" onclick="ModC('2')">
<input type="button" name="B3" onclick="ModC('3')">

<input type="hidden" name="property_key" value="0">
function ModC(a)
document.form1.property_key.value = a
document.form1.submit()
End Function

Now, I want also to change ACTION parm on the FORM, so depending on
some calculation ACTION=MODIFY.ASP or ACTION=SHOW.ASP

I tried:
<input type="button" name="B1"
onclick="document.form1.action ='MODIFY.ASP' ; ModC('1')">

this didn't work. Any ideas how to solve this problem?

Thanks,

Zalek
Jul 20 '05 #1
3 60077
Jim
You can set the action property for a form within a javascript function,
then submit the form. Hope the following helps

jim cant

function handleClick( form )
{
form.action = "yourDesiredPage.jsp";
form.submit();
}
.....
<form name="theForm" action="DONT_CARE" method="POST" >
.....
<input type="button" onclick=handleClick(this.form)
value="ClickHere" />
</form>
.....

"Zalek Bloom" <Za********@hotmail.com> wrote in message
news:mu********************************@4ax.com...
Hello,

Here is my problem:
I am displaying to a user a row of buttons. Depending on which button
user presses, I want to go to a different URL and to give a different
value to a hidden variable.

My code is:
<FORM NAME=FORM1 ACTION="">
<input type="button" name="B1" onclick="ModC('1')">
<input type="button" name="B2" onclick="ModC('2')">
<input type="button" name="B3" onclick="ModC('3')">

<input type="hidden" name="property_key" value="0">
function ModC(a)
document.form1.property_key.value = a
document.form1.submit()
End Function

Now, I want also to change ACTION parm on the FORM, so depending on
some calculation ACTION=MODIFY.ASP or ACTION=SHOW.ASP

I tried:
<input type="button" name="B1"
onclick="document.form1.action ='MODIFY.ASP' ; ModC('1')">

this didn't work. Any ideas how to solve this problem?

Thanks,

Zalek

Jul 20 '05 #2
Zalek...

I took the form you had, except I put values on the buttons, and I rewrote
the script. I performed a calculation to check if a is odd or even, which
tells me which button was clicked, by using the vbscript command MOD with a
value of 2. If it returns a 1 (odd), then I set the action of the form to
modify.asp. If it returns a 0 (even) then I set the action to view.asp.

Remove the alerts. Remove the comment tags in the script to submit the form
and set the return to true.
Perhaps this will give you some ideas to get your script working the way you
want it to.

http://kiddanger.com/lab/form0.html

"Zalek Bloom" <Za********@hotmail.com> wrote in message
news:mu********************************@4ax.com...
Hello,

Here is my problem:
I am displaying to a user a row of buttons. Depending on which button
user presses, I want to go to a different URL and to give a different
value to a hidden variable.

My code is:
<FORM NAME=FORM1 ACTION="">
<input type="button" name="B1" onclick="ModC('1')">
<input type="button" name="B2" onclick="ModC('2')">
<input type="button" name="B3" onclick="ModC('3')">

<input type="hidden" name="property_key" value="0">
function ModC(a)
document.form1.property_key.value = a
document.form1.submit()
End Function

Now, I want also to change ACTION parm on the FORM, so depending on
some calculation ACTION=MODIFY.ASP or ACTION=SHOW.ASP

I tried:
<input type="button" name="B1"
onclick="document.form1.action ='MODIFY.ASP' ; ModC('1')">

this didn't work. Any ideas how to solve this problem?

Thanks,

Zalek
Jul 20 '05 #3
"which button was clicked" should read which button of which group was
picked (odd or even) button 1 and 3 = odd, etc.

"Roland Hall" <nobody@nowhere> wrote in message
news:O%****************@tk2msftngp13.phx.gbl...
Zalek...

I took the form you had, except I put values on the buttons, and I rewrote
the script. I performed a calculation to check if a is odd or even, which
tells me which button was clicked, by using the vbscript command MOD with a
value of 2. If it returns a 1 (odd), then I set the action of the form to
modify.asp. If it returns a 0 (even) then I set the action to view.asp.

Remove the alerts. Remove the comment tags in the script to submit the form
and set the return to true.
Perhaps this will give you some ideas to get your script working the way you
want it to.

http://kiddanger.com/lab/form0.html

"Zalek Bloom" <Za********@hotmail.com> wrote in message
news:mu********************************@4ax.com...
Hello,

Here is my problem:
I am displaying to a user a row of buttons. Depending on which button
user presses, I want to go to a different URL and to give a different
value to a hidden variable.

My code is:
<FORM NAME=FORM1 ACTION="">
<input type="button" name="B1" onclick="ModC('1')">
<input type="button" name="B2" onclick="ModC('2')">
<input type="button" name="B3" onclick="ModC('3')">

<input type="hidden" name="property_key" value="0">
function ModC(a)
document.form1.property_key.value = a
document.form1.submit()
End Function

Now, I want also to change ACTION parm on the FORM, so depending on
some calculation ACTION=MODIFY.ASP or ACTION=SHOW.ASP

I tried:
<input type="button" name="B1"
onclick="document.form1.action ='MODIFY.ASP' ; ModC('1')">

this didn't work. Any ideas how to solve this problem?

Thanks,

Zalek

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Scott Townsend | last post by:
I'd like to pass parameters to a local Application from a webpage. something like: <a href="file:///C:/Program%20Files/myapp/myapp.exe%20-custno:mycustno%20-quote no:12345%20-item:12345">test...
13
by: Al Franz | last post by:
Anyone understand how to pass parameters to a JavaScript. If anyone finds this easy to do maybe they could take a look at my short script on this page and show me how it needs to be changed. ...
5
by: Ben | last post by:
Hi I am using a User Control which is referenced by an ASPX page. How can I pass a string parameter to the user control, from the base ASPX page. Thanks Ben
6
by: Woody Splawn | last post by:
I am using SQL Server 2000 as a back-end to a VS.net Client/Server app. In a certain report I use a view as part of the query spec. For the view, at present, I am querying for all the records in...
3
by: Wang Xiaoning | last post by:
I have an customerdetail.xsl sheet ---------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"...
3
by: Joseph Lu | last post by:
Hi, all I have a stored procedure created in SQL Server like the following lines. // stored proceudre code starts here CREATE PROCEDURE sp_insertdata @strdata varchar(250) , @rsult BIT...
0
by: raghuraman_ace | last post by:
Hi i have started a webservice wich has a webmethod with parameters using literal encoding & encoded encoding . The webservice is compiled successfully . But i don know how to pass the...
0
by: PriyaManasarovar | last post by:
Can someone help how to pass parameters to a crystal report using a Crystal report object? I am using a console application & hence crystal report viewer cannot be used. And i need to pass the...
3
by: Aussie Rules | last post by:
Hi, I have a few aspx (.net2) form. The first form allows the user to enter into text box, and select values from drop downs The second form needs to use these values to process some data....
3
by: Vajrala Narendra | last post by:
Hi all Hi all, In my WF Project i have a CodeActivity, that is to check wether entered userid, password are valid or not how to pass parameters to CodeActivity. what i tried is in my class i...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.