473,670 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.va lue = a
document.form1. submit()
End Function

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

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

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

Thanks,

Zalek
Jul 20 '05 #1
3 60093
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 = "yourDesiredPag e.jsp";
form.submit();
}
.....
<form name="theForm" action="DONT_CA RE" method="POST" >
.....
<input type="button" onclick=handleC lick(this.form)
value="ClickHer e" />
</form>
.....

"Zalek Bloom" <Za********@hot mail.com> wrote in message
news:mu******** *************** *********@4ax.c om...
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.va lue = a
document.form1. submit()
End Function

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

I tried:
<input type="button" name="B1"
onclick="docume nt.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********@hot mail.com> wrote in message
news:mu******** *************** *********@4ax.c om...
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.va lue = a
document.form1. submit()
End Function

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

I tried:
<input type="button" name="B1"
onclick="docume nt.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%******** ********@tk2msf tngp13.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********@hot mail.com> wrote in message
news:mu******** *************** *********@4ax.c om...
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.va lue = a
document.form1. submit()
End Function

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

I tried:
<input type="button" name="B1"
onclick="docume nt.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
1876
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 with params</a></p> Though it does not like it. If I leave off the Parameters it works fine.
13
26982
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. http://franz.org/java.htm Thanks for any help.
5
3946
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
3567
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 the table. But I am wondering if there is a way, at runtime, to pass values to the View (like start date and end date) so that I don't have to return every record in the table of my view. If I can't pass a parameter, perhaps I can create a view,...
3
2110
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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="customer_number"></xsl:param>
3
8210
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 OUTPUT , @erridx CHAR(7) OUTPUT
0
2083
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 parameters that satisfy these encodings . My web method is ---------------------------------------------
0
2103
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 parameter through a batch file at run time? I have included a code here to pass parameters, but its giving invalid index error when i try to pass parameters: report1 = app.OpenReport(sfilename) crxDatabase = report1.Database ...
3
3174
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. I am currently using the url to pass the values such as
3
2785
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 wrote a method of bool type with userid, password as parameters, am checking here wether values are correct or not according to that am returning bool value. am entering userid, password values from a window form which is in otherproject of the...
0
8466
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8813
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7412
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6212
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1791
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.