473,473 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Passing a conditional form variable (Was: 'Trying to use images asform submit buttons')

Okay, I made sense of the earlier suggestions and realized I was on the
right track -- I appreciate the feedback which got me to this point.

The suggestions posted here indeed worked and eliminated the JavaScript
errors I was seeing. The fact that the target URL didn't execute was
because certain variables weren't being passed to it.

What I need to do is to pass a conditional variable to the target URL,
when the form is submitted, depending on which graphic button is pressed.

So, the form already sends several variables when the form is submitted
(at the onclick event). I've confirmed this by capturing the HTTP POST
variables and displaying them when the page executes.

Now, depending on which graphic button is selected, I would like to pass
another variable.

For example, when the Create button is pressed, I would like to pass
create=true (or something signifying that 'create' is set) to the target
URL.

How would I accomplish this? Any suggestions?

- Orest

On 2003-08-27 11:38 PM, Orest Kinasevych Saj remarked:
I'm trying to use images as form submit buttons along with JavaScript
but am having trouble getting these to work correctly. JavaScript
isn't one of my strengths.

Here's the current incarnation of my form and script (stripped to the
essentials):

----
<form name='frmcontact' method='post' enctype='multipart/form-data'>

Name:<input name='fname' type='text' size='10' value=''>

<input type='image' name='create' src='save.gif'
onclick='document.form.action="contacts.php"'>

</form>
----

The form executes correctly -- ie, all parameters are passed to the
target URL and processed correctly. (Not shown here in the interest
of simplicity are several input items of type=hidden. None of those
inputs has a name or value of 'action'.)

The problem is that IE and Mozilla complain of a JavaScript error.

The following error appears in IE6/Win:

----
'document.form' is null or not an object
----

The Mozilla JavaScript debugger reports the following error:

----
document.form has no properties
----
I've tried several variations and have consulted all requisite
resources for guidance, all to no avail.

Please help!


Jul 20 '05 #1
1 4293
> Now, depending on which graphic button is selected, I would like to pass
another variable.

For example, when the Create button is pressed, I would like to pass
create=true (or something signifying that 'create' is set) to the target
URL.


You could give your image tags names, like this:

<input type="image" src="create.gif" name="create" />
<input type="image" src="delete.gif" name="delete" />

on the other side in the form collection, you will see the x and y
coordinates of the image they pressed, such as

create.x = 34

delete.x = 46

so you can test for the length > 0 of create.x or delete.x
hope I have understood your problem correctly.
Sean Jorden
Norada Corp.
Jul 20 '05 #2

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

Similar topics

3
by: sentinel | last post by:
Hi, Wonder if anyone can help with this problem: I am using an app with several pages, using a session to track vars between the pages, and using an image map to re-direct back and forwards...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
10
by: Dave Smithz | last post by:
Hi there, I have a situation where I want to have multiple submit buttons on the same form and therefore want to use a redirection php script that checks the value associated with the submit...
1
by: Newbie | last post by:
OK, this may be impossible since I'm using 3rd party shopping cart ASP software, but I've been able to finagle a lot of other stuff I thought wouldn't work, so here we go: I'm using a form in...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
1
by: Dave | last post by:
Hi all, I was trying to make an image submit button with a rollover and discovered to my suprise that there is no way to access a form element of the "image" type. I tried specifying it by name...
5
by: Raffi | last post by:
Hi, I have a form that has 2 submit buttons. The form action is a php script. What I'm trying to do is to execute a different javascript function depending on which submit button is pressed. So...
25
by: Dave | last post by:
Hello. In trying to get an anchor element to stylistically match an input or button element, I find that the button and input cannot be styled according to the 2.1 CSS spec. For example, I...
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
0
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...
0
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,...
0
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...
0
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...
0
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
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...

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.