473,320 Members | 2,158 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,320 software developers and data experts.

Click on an Image, and set radio button value to true

Hi guys,

I'm a pretty good PHP programmer, but when it comes to JS, I just dont
understand it! But I really need to learn. I'm having trouble doing
the simplest thing!

When someone clicks on this image, I want the radiobutton above it to
be checked. Not that hard,but nothing I try seems to work. Can
someone please help me?
<form id="form1" method="post" action="">
<input type="radio" name="radio" id="svc_tp_1" value="svc_tp_04" /></
td>
<img src="images/print.jpg" onClick="check('svc_tp_1')" />
Jul 18 '08 #1
9 9837
dcx
Do you really need javascript?

Why not:

<label><input type="radio"/><img/></label>
Jul 19 '08 #2
"dcx" <Yo*************@gmail.comwrote:
: <label><input type="radio"/><img/></label>

Is that something new? It doesn't look like HTML nor XHTML. I'm
curious. Did I miss out on something?

--
Jim Carlock
Natural Cure For Pink-Eye (Conjunctivitis)
http://www.associatedcontent.com/art...nctivitis.html


Jul 19 '08 #3
ameshkin wrote:
I'm a pretty good PHP programmer, but when it comes to JS, I just dont
understand it! But I really need to learn. I'm having trouble doing
the simplest thing!
Apparently.
When someone clicks on this image, I want the radiobutton above it to
be checked. Not that hard,but nothing I try seems to work. Can
someone please help me?

<form id="form1" method="post" action="">
<input type="radio" name="radio" id="svc_tp_1" value="svc_tp_04" /></
td>
<img src="images/print.jpg" onClick="check('svc_tp_1')" />
Reduced to the necessary minimum (HTML 4.01 Transitional) and all invalid
code dumped to /dev/null:

<form action="" method="post">
<input type="radio" name="radio" id="svc_tp_1" value="svc_tp_04"
><label for="svc_tp_1"><img
src="images/print.jpg" alt="Print"></label>
<input type="submit">
</form>

Sorry, looks like there is no JS in there. But maybe someone else comes up
with a fully-fledged scripted solution that introduces the accessibility issue.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jul 19 '08 #4
Jim Carlock wrote:
"dcx" <Yo*************@gmail.comwrote:
: <label><input type="radio"/><img/></label>

Is that something new?
No, it turns 10 on December 24 next year.
It doesn't look like HTML nor XHTML.
*The above* is not. However, it can be written as Valid HTML 4.01 or
XHTML 1.x. See my other reply.
I'm curious. Did I miss out on something?
Obviously.

<http://www.w3.org/TR/REC-html40/>
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jul 19 '08 #5
On Jul 19, 4:37*am, ameshkin <amir.mesh...@gmail.comwrote:
Hi guys,

I'm a pretty good PHP programmer, but when it comes to JS, I just dont
understand it! *But I really need to learn. *I'm having trouble doing
the simplest thing!

When someone clicks on this image, I want the radiobutton above it to
be checked. *Not that hard,but nothing I try seems to work. *Can
someone please help me?

<form id="form1" method="post" action="">
<input type="radio" name="radio" id="svc_tp_1" value="svc_tp_04" /></
td>
<img src="images/print.jpg" onClick="check('svc_tp_1')" />

If you really want to select the radio button, by using JavaScript,
without using <labelelement,
then the following code will help you.
<img src="images/print.jpg" alt="Print"
onClick="document.getElementById('id_of_your_radio _button').checked =
true;">
Jul 19 '08 #6
Suhas Dhoke wrote on 19 jul 2008 in comp.lang.javascript:
If you really want to select the radio button, by using JavaScript,
without using <labelelement,
then the following code will help you.
<img src="images/print.jpg" alt="Print"
onClick="document.getElementById('id_of_your_radio _button').checked
true;">
......).checked = true;">

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '08 #7
SAM
Jim Carlock a écrit :
"dcx" <Yo*************@gmail.comwrote:
: <label><input type="radio"/><img/></label>

Is that something new? It doesn't look like HTML nor XHTML. I'm
curious. Did I miss out on something?

<labelin forms is pure html

very useful for accessibility
<p><label for="theId">Please hit me to check the radio button choice
1</label>
<input type="radio" id="theId" name="choice" tabindex=10
value="choice_1"choice 1</p>

So that could work with an image

<p>
<label for="theId">
<img src="choice_1.gif" alt="button helper"
tittle="hit me to check choice 1">
</label>
<input type="radio" id="theId" name="choice"
tabindex=10 value="choice_1">
choice 1
</p>
--
sm
Jul 19 '08 #8
On Jul 18, 4:37*pm, ameshkin <amir.mesh...@gmail.comwrote:
Hi guys,

I'm a pretty good PHP programmer, but when it comes to JS, I just dont
understand it! *But I really need to learn. *I'm having trouble doing
the simplest thing!

When someone clicks on this image, I want the radiobutton above it to
be checked. *Not that hard,but nothing I try seems to work. *Can
someone please help me?

<form id="form1" method="post" action="">
<input type="radio" name="radio" id="svc_tp_1" value="svc_tp_04" /></
td>
<img src="images/print.jpg" onClick="check('svc_tp_1')" />
onClick="document.getElementById('svc_tp_2').check ed =
true;"

Thanks guys,
The above is exactly what I was lookng for. i almost had it myself,
but because of a typo, it did not work correctly!

I really need to buy a js book. Javascript is not really powerful,
but there are many things you can do with it that are impossible with
other languages, which does make it very powerful in its own way.
Jul 21 '08 #9
ameshkin wrote:
[...]
onClick="document.getElementById('svc_tp_2').check ed = true;"

Thanks guys,
The above is exactly what I was lookng for.
It's not. To begin with, it uses host object's methods without
feature-testing for them first.
i almost had it myself, but because of a typo, it did not work correctly!

I really need to buy a js book.
Hardly. In fact, at this point my recommendation stands that no book about
JS is worth buying for a beginner. There is plenty of reference material
online, for free. While subscribing to this newsgroup and reading regularly
is generally a good idea when attempting to learn the language(s), you
should start with the newsgroup's FAQ <http://jibbering.com/faq/and go
from there.
Javascript is not really powerful, [...]
As a *beginner* talking about *"Javascript"* when there is no such language,
you are not exactly in a position to correctly assess the power of the
several different implementations of the ECMAScript Language Specification.

<http://PointedEars.de/es-matrix>
HTH

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jul 22 '08 #10

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

Similar topics

1
by: Jawahar Rajan | last post by:
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...
4
by: Csaba2000 | last post by:
I want to be able to programatically click on the center of an <INPUT type=image ...> element (I only care about IE 5.5+). This should work regardless of whether IE has focus. Normally you would...
1
by: David Wake | last post by:
I have two radio buttons and two checkboxes in a form. I'm trying to write some code so that when a radio button is selected, its corresponding checkbox is disabled. My code looks like this: ...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
5
by: mayur_hirpara | last post by:
Hi, I have been developing web applications for a while now. However, as I was thinking through the architecture I really don't understand the "How server can identify between which buttons has...
9
by: IchBin | last post by:
I can not see what the problem is with this script. I am just trying to set a radio button by calling setCheckedValue('abbr_letter', 'V'). Sorry I am new to javascript. <html> <head> <script...
7
by: IchBin | last post by:
I am trying to programmatically set a radio button in a table of radio buttons. I have two problems with the code below: 1 - I can not prepare the <Formstatement to be printed by php. (syntax...
2
by: chrisp | last post by:
I have an ASP.NET 2 page with a button that causes a credit card transaction to be authorised. The authorisation procedure may take a few seconds and so I want to prevent the user from clicking the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.