Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
use jquery to select a radiobutton in MVC
Old 02-25-2011, 06:56 PM use jquery to select a radiobutton in MVC
DmitryS's Avatar
Skilled Talker

Posts: 84
Trades: 0
Hi there,
i have 3 images in my view..
<img id="flyer1" src=".." alt="" />
<img id="flyer2" src=".." alt="" />
<img id="flyer3" src=".." alt="" />
and 3 radiobuttons
@Html.RadioButtonFor(m => m.FlyerName, "flyer1", new { id = "rad1"})
@Html.RadioButtonFor(m => m.FlyerName, "flyer2", new { id = "rad2"})
@Html.RadioButtonFor(m => m.FlyerName, "flyer3", new { id = "rad3"})

How would I with the help of jquery make the radiobutton (rad1) selected when the user clicks on the img (flyer1), rad2 selected when flyer2 is clicked and so on.
I tried
$('flyer1').onclick(){
$("#rad1").Selected;
}
This doesn't work. Any ideas?
__________________
»
Please login or register to view this content. Registration is FREE
for web developers
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
DmitryS is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-26-2011, 03:28 PM Re: use jquery to select a radiobutton in MVC
chrishirst's Avatar
Defies a Status

Posts: 43,957
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Why would you need the overhead of jquery to do something so simple?

Code:
<script type="javascript">
radSelect(p_id) {
     var RadID = p_id.replace('flyer','rad');
     document.getElementById(RadID).selected = true;
}
<script>
Then add
Code:
onclick="radSelect(this.id)";
to the image tag
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to use jquery to select a radiobutton in MVC
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13221 seconds with 11 queries