473,785 Members | 2,482 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_0 4" /></
td>
<img src="images/print.jpg" onClick="check( 'svc_tp_1')" />
Jul 18 '08 #1
9 9904
dcx
Do you really need javascript?

Why not:

<label><input type="radio"/><img/></label>
Jul 19 '08 #2
"dcx" <Yo************ *@gmail.comwrot e:
: <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_0 4" /></
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_0 4"
><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.comwrot e:
: <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...@g mail.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_0 4" /></
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="docume nt.getElementBy Id('id_of_your_ radio_button'). checked =
true;">
Jul 19 '08 #6
Suhas Dhoke wrote on 19 jul 2008 in comp.lang.javas cript:
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="docume nt.getElementBy Id('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.comwrot e:
: <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">Ple ase 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.g if" 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...@g mail.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_0 4" /></
td>
<img src="images/print.jpg" onClick="check( 'svc_tp_1')" />
onClick="docume nt.getElementBy Id('svc_tp_2'). checked =
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="docume nt.getElementBy Id('svc_tp_2'). checked = 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
18783
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 image4 - reSet user.
4
17257
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 do myDomElement.click and the mouse doesn't matter, but in the case of an input image element, what happens is the submitted url has something like "?x=12&y=7" appended to it (the numbers vary per mouse position on the clicked element). If you hit...
1
6218
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: function radioClicked(index) { document.table_config_form.my_checkbox.disabled = true;
10
13462
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 related to checkboxes. Thanks!!!
5
3110
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 user clicks on the "Choose" button of the input field (to select a file on the local disk), then radio button B is automatically
5
2459
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 made the postback request.???" for e.g. I have a webpage default.aspx. I place TWO or more server buttons on it. Create server-side event handlers for each of the buttons.
9
2254
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 type="text/javascript"> function setCheckedValue(radioObj, newValue) { if(!radioObj)
7
3337
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 of the hyphens, quotes) my fault! 2 - If I delete the <Formand </Formstatements I can build the table of radio buttons correctly, HTML wise. The fifth radio button has 'checked=True'. The problem is even though I set radio button 5 to be...
2
2816
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 button again (or at least detect that an authorisation is already in progress and do nothing) while the first authorisation is in progress. Can someone help me out? I've tried the following but none of the solutions work: 1) Disabling the...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10324
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
10090
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,...
0
9949
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...
1
7499
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
5380
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...
1
4050
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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.