Solved

Accessing <input type=image > control in script

Posted on 2002-06-06
13
155 Views
Last Modified: 2010-04-09
I have a problem in accessing the following control
<input type=image name=xyz src=xyz.gif value="insert">
When i want to refer it with its name as follows

<script>
document.frmsamp.xyz.src="abc.gif";
document.frmsamp.xyz.value="Update";
</script>

It shows an error : null or not an object.
0
Comment
Question by:Paramaguru
  • 5
  • 4
  • 2
  • +2
13 Comments
 

Author Comment

by:Paramaguru
ID: 7059008
I have used <input type=image> for form submit.
But it shows error when i want to change that "src" attribute and value attribute in form load event in script.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7059043
Image type inputs are an alternate to submit.  They act the same way and their attributes are not exposed to scripting.  The value would be ignored in any case.  If you want to dynamically modify the image you will need to use an image link.

Cd&
0
 
LVL 18

Expert Comment

by:bruno
ID: 7059116
not sure how the "value" attribute is even used on an input type="image"....


BRUNO
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7059152
Cd& is correct ... here is the proof:

<HTML>
<HEAD>
<SCRIPT language='javascript'>

function onLoadHandler(theForm)
{
  alert(theForm.elements.length);  // shows that the image is not an element of the form

  var s="";
  for ( o in theForm )
     s+=o+", ";
  alert(s);   // shows all other form properties, none of which is the image
}

</script>
</head>

<BODY onLoad='onLoadHandler(document.myform);'>

<FORM name='myform'>
 <INPUT type='image' name='YYZ' src='YYZ.gif' value='insert'>
</form>

</body>
</html>



so the solution (as Cd& pointed out) would be to use a linked-image and a hidden field to store your "insert" or "update" values:

<A href="Submit" onClick="document.images['submit'].src='update.gif';document.myform.myhidden.value='update';document.myform.submit();">
<IMG name='submit' src='insert.gif'>
</a>
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 50 total points
ID: 7059156
oops, forgot the return false; at the end of the onClick:

onClick="document.images['submit'].src='update.gif';document.myform.myhidden.value='update';document.myform.submit();return false;">
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7059181
I believe that the value sent for an input image is the x/y co-ordinates in the image.

Cd&
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 33

Expert Comment

by:knightEknight
ID: 7059184
value sent to the server, correct ... but this is not accessible via client script.
0
 
LVL 3

Expert Comment

by:malcx
ID: 7061355
note that the x/y can be sent as 0, which == false in some server languages...
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7079426
Paramaguru,

Is there some reason you are ignoring the experts trying to help you?

Cd&
0
 
LVL 18

Expert Comment

by:bruno
ID: 7146403

Hello,

This question has been open for quite a while now and needs to be wrapped up.

EXPERTS: If any of the experts could come back and post any suggestions as to how they feel this could be wrapped up (delete, 0 PAQ, award points, etc), I'm sure the moderators would appreciate it.  If you feel you deserve points here, but don't care to respond, the question might very well get DELETED.

ASKER:  Please return and finalize this question.  Abandoning a question is in violation of the member agreement.

Please do NOT accept this comment as an answer, as I am simply trying to alert those involved that the question is still open.

Thank you,

BRUNO
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7146659
I gave the correct answer and the appropriate option.  Solution in 38 minutes and still no user responses :^(

Cd&
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7146859
agree, points to Cd& IMO
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7154093
????

Cd&
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now