473,769 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ 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='frmcontac t' method='post' enctype='multip art/form-data'>

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

<input type='image' name='create' src='save.gif'
onclick='docume nt.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 4310
> 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
3989
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 between the pages. The way I redirect is when the image map is clicked on, it posts to a page called 'control.php' which passes the POST vars to the
1
7789
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: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
10
3265
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 form variable to calculate which submit was pressed and then redirects the user to another php page accordingly. I used: headers ("location:myphpscript.php")
1
7436
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 which users enter numbers to be calculated into a square footage cost. Upon submitting, the results page uses ASP to give the total and the chance to add the new totalled item to the cart or try a new calculation. Part of the cart's software has a...
3
14949
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) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
1
3051
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 and also by the elements array with no luck. Even weirder, I can sandwich an image button in between other input types and then write a script diplaying the contents of the elements array and it acts as if the image button does not exist at all!...
5
6389
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 far I've tried the following with no success. In the code below, a different function would execute based on the value of the "flag" variable. <HTML> <HEAD>
25
2476
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 expected this ruleset: ..but { display: block; background-color: red; font-size: 14px; text-decoration: none; line-height: 16px; width: auto; height: 16px; padding: 0; margin: 0;
16
2880
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 ass and the app will be used internally so I'm not too worried about users who aren't using javascript. I'm using the following javascript to detect whether or not they've hit enter: if(document.layers) {
0
9423
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
10219
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...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7413
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...
0
5310
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
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 we have to send another system
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.