473,748 Members | 3,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Input Type = "Image"

All,
I am using a few Input type of "Image" instead of a classic submit button in
a form to achieve various tasks

for example
image1 - add user
image2 - modify user
image3 - delete user
image4 - reSet user.

These are only image and I use the onClick event to run JavaScript function
called whichPage

Function whichPage(nextP age)
{
if (nextPage = = 'addUser')
document.frmAdm in.action="Admi nNewUser.asp"
if (nextPage = = 'modUser')
document.frmAdm in.action="Admi nModUser.asp"
if (nextPage = = 'delUser')
document.frmAdm in.action="Admi nDelUser.asp"
if (nextPage = = 'resetUser')
document.frmAdm in.action="Admi nResetUser.asp"

}
in the main form there is a list of users with a radio button to each user.
What I want to do is to check that at least one radio button is selected
when the image2, image3 or image4 is clicked.
I have tried to use onClick="return whichPage()"
But I do not think that returning "false" to the onClick event works because
of the document.frmAdm in.action=".... " will re-route the page before it can
return.
So my queation is how can I check that At least one radio button is checked
when one of the three images in question are clicked.
The form on Submit is no good because it will also check it when Image1 is
clicked and I do not want; as this adds a new user and hence an existing one
does not need to be selected.

Any suggestions or ideas will be appreciated

Thanks
Jawahar

Jul 20 '05 #1
1 18781
Jawahar Rajan wrote:
All,
I am using a few Input type of "Image" instead of a classic submit button in
a form to achieve various tasks

for example
image1 - add user
image2 - modify user
image3 - delete user
image4 - reSet user.

These are only image and I use the onClick event to run JavaScript function
called whichPage

Function whichPage(nextP age)
{
if (nextPage = = 'addUser')
document.frmAdm in.action="Admi nNewUser.asp"
if (nextPage = = 'modUser')
document.frmAdm in.action="Admi nModUser.asp"
if (nextPage = = 'delUser')
document.frmAdm in.action="Admi nDelUser.asp"
if (nextPage = = 'resetUser')
document.frmAdm in.action="Admi nResetUser.asp"

}

in the main form there is a list of users with a radio button to each user.
What I want to do is to check that at least one radio button is selected
when the image2, image3 or image4 is clicked.
I have tried to use onClick="return whichPage()"
But I do not think that returning "false" to the onClick event works because
of the document.frmAdm in.action=".... " will re-route the page before it can
return.
So my queation is how can I check that At least one radio button is checked
when one of the three images in question are clicked.
The form on Submit is no good because it will also check it when Image1 is
clicked and I do not want; as this adds a new user and hence an existing one
does not need to be selected.

Any suggestions or ideas will be appreciated

Thanks
Jawahar


Setting the action attribute of a form does not cause the form to be submitted,
so all your function is doing is setting the action on the form, the onclick
event returns and the default behavior of the <input type="image" ...> takes
place (that it, it submits the form).

Returning false to the onclick event of <input type="image" ...> will prevent
the form from being submitted. You've also got some syntax errors in your code,
and you probably want to write it as a switch to make it clearer what you're
doing.

function whichPage(image Input, nextPage) {
var f = imageInput.form ;
var theUserRadios = f.elements['userRadio'];
var userPicked = false;

if (typeof theUserRadios.l ength == 'undefined') {
// normalize a single radio to an array
theUserRadios = [ theUserRadios ];
}

// look at each radio input to see if it's selected
for (var i = 0; i < theUserRadios.l ength; i++) {
if (theUserRadios[i].checked) {
userPicked = true;
break;
}
}

if (userPicked) {
// if a radio input was picked, change the action
var formAction;
switch(nextPage ) {
case 'addUser':
formAction = "AdminNewUser.a sp";
break;
case 'modUser':
formAction = "AdminModUser.a sp";
break;
case 'delUser':
formAction = "AdminDelUser.a sp";
break;
case 'resetUser':
formAction = "AdminResetUser .asp";
break;
}
imageInput.form .action = formAction;
} else {
// no user picked
alert('You must pick a user first.');
}

return userPicked;
}

It's called with <input type="image" ... onclick="return whichPage(this,
'addUser');" /> etc

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

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

Similar topics

1
3050
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!...
1
1779
by: zelnugget | last post by:
I'm using a fading image script that I found via Google Groups on this newsgroup, and am having some difficulty with it. First, here's a link to the Google Groups posting: http://groups-beta.google.com/group/comp.lang.javascript/msg/3f287a2f20de1b10 I've modified the page linked to in the above URL by making one of the images an input element whose type is an image and am now encountering flickering problems. Here's the webpage:
2
4231
by: Mr.Clean | last post by:
If I have an Input of type image, it is not listed in the Forms elements when walking to DOM using MSHTML. Is this expected behaviour and how would I get the image input to submit the form NOT using document.form.submit?
0
1207
by: Brian Kitt | last post by:
I am developing my website in C#, and making all buttons "Input Type=Image", because I want rollover capabilities. They work perfectly, as long as the user is using the mouse. I have one web page that has 3 different buttons. I would like the enter key to default to a specific button (or one specific function). How do I do that?
17
3208
by: Alan Silver | last post by:
Hello, I have a page which I am converting to use themes. The page has an HTML <input type="image"> element that is used to post to another page. I would like to replace this with a server control so I can add a skinid. I tried adding runat="server" and the skinid to the existing control, but that didn't work. Any other ideas? TIA --
2
2763
by: Alan Silver | last post by:
Hello, If I have the following HTML... <input type="image" src="fred.gif"> .... is there a way to specify the image in CSS rather than in the HTML? TIA
21
21346
by: cman | last post by:
does anyone know why i can't generate images with: header("Content-type:image/jpeg"); imagejpeg($img_number); i've tried different examples but i always get a text output as if the header doesn't make a difference at all. <?php //random_number.php $img_number = imagecreate(100,50);
5
7918
by: Mark Woodward | last post by:
Hi all, I'm trying to set up a 'control panel' consisting of a table of icons. The early stages: http://www.deepinit.com/controlcentre.php Each of these is set up like: <td> <input type="image" id="addnews" src="/Image/add24.png"
3
2036
by: PJ6 | last post by:
Embedded javascript can be served from a DLL with an include that uses a special URL generated by the Page.ClientScript.GetWebResourceUrl method at runtime. For example: <script src="/DEV-WEB/WebResource.axd?d=Fzr7sc4IZAELIE4FCpgaNkpd1YgQqgig1EfiFj9_b7U1&t=633202779231250800"type="text/javascript"></script> .... so can style sheets: <link rel="stylesheet" type="text/css"
0
9247
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
8243
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
6796
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
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
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
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
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
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.