473,413 Members | 1,679 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,413 software developers and data experts.

<input type="image" ... does not show up as a form element! why?

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!
For example the following:
<input type="text" ... > : this is elements[0]
<input type="checkbox" ...> : this is elements[1]
<input type="image" ...> : this does not exist!
<input type="text" ...> : this is elements[2]

Does anyone know of any way to access (or set) the properties of an image
input type?
I ask, because I wanted to have a rollover action on a button that also can
POST a form WITHOUT using submit() - in order that non-Javascript enabled
browsers can fail gracefully (i.e. the form is still POSTed).
TIA!
MC Dave
Jul 23 '05 #1
1 3008
Solution:
Because the "image button" is not accessible via the elements collection nor
by directly naming it (i.e. forms[0].elements[5] OR myform.BTNcontinue)
BUT you can utilize "this" to change a property directly as in the example
below where a rollover can be specified directly:

<INPUT TYPE="image" name="BTNcontinue"
src="images/buttons/btncontinueshopping.gif"
onmouseover="this.src='images/buttons/btncontinueshopping_f2.gif'"
onmouseout="this.src='images/buttons/btncontinueshopping.gif'">

To reference it from an outside script:
<INPUT TYPE="image" name="BTNcontinue"
src="images/buttons/btncontinueshopping.gif" onmouseover="rollon(this);"
onmouseout="rolloff(this);">

<script language="JavaScript">

function rollon(myref)
{
myref.src='images/buttons/btncontinueshopping_f2.gif';
}

function rolloff(myref)
{
myref.src='images/buttons/btncontinueshopping.gif';
}

</script>

"Dave" <dave(delete_this)@miraclecatDELETETHISTOO.com> wrote in message
news:V_Xdc.4287$xn4.17460@attbi_s51...
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!
For example the following:
<input type="text" ... > : this is elements[0]
<input type="checkbox" ...> : this is elements[1]
<input type="image" ...> : this does not exist!
<input type="text" ...> : this is elements[2]

Does anyone know of any way to access (or set) the properties of an image
input type?
I ask, because I wanted to have a rollover action on a button that also can POST a form WITHOUT using submit() - in order that non-Javascript enabled
browsers can fail gracefully (i.e. the form is still POSTed).
TIA!
MC Dave

Jul 23 '05 #2

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

Similar topics

3
by: news | last post by:
I'm working with a CGI program that was using several standard buttons for input using <input type="submit" name="abuttonName" ... Now, I'm trying to replace the standard buttons with images...
5
by: Mikko Rantalainen | last post by:
See example at <URL:http://www.cc.jyu.fi/~mira/moz/formtest.php>. The problem is that the label of submit button is always centered on the button regardsless of 'text-align' property in CSS....
1
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic...
17
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...
2
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
3
by: Bill | last post by:
Hi In a css page I have the following: ..OLC{float:left; width:150px;text-align:center; } OL{ list-style-position:inside;} LI{ height:160px;}
3
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...
3
by: =?Utf-8?B?V2lsbA==?= | last post by:
I have an image "button" which causes a postback. I handle the "click" with If Request.Form("btnBU7WD6_Submit.X") 0 Then... this works great. However, when a user double-clicks the image...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
0
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...

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.