- for($i = 1; $i <= 15 ; $i++){
-
for($k = 1; $k <= 10 ; $k++){
-
$myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."' value='". $k ."' disabled='true' $chk title='". $k." out of 10 ' />";
-
}
-
}
-
$myresult .= "<a href='#' id=\"rate-it\" onclick=\"test('rating".$i."');\">Rate It</a>";
-
<script type='text/javascript'>
-
function test(name){
-
document.ratings.rating1.disabled = false;
-
document.ratings.rating2.disabled = false;
-
document.ratings.rating3.disabled = false;
-
alert('hai');
-
}
hi i am working on a product site where in i display 10 radio button for 15 features of a product for user to rate . and each check box is disabled by default and i add a rate it button "rate-it" which on click should enable 1 row of checkboxes . i tried to write code for tht . its print the alert msg and all. but enabling the checkboxes is not working any help on it!?
19 6565
Hi,
This is a sample code.... - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
<HTML>
-
<HEAD>
-
<TITLE> New Document </TITLE>
-
<META NAME="Generator" CONTENT="EditPlus">
-
<META NAME="Author" CONTENT="">
-
<META NAME="Keywords" CONTENT="">
-
<META NAME="Description" CONTENT="">
-
<script type="text/javascript">
-
function enableRadio(rdId)
-
{
-
//alert(rdId);
-
document.getElementById(rdId).disabled=false;
-
}
-
</script>
-
</HEAD>
-
-
<BODY>
-
<input type="radio" name="demoRadio" id="demoRadio" disabled="disabled"/>
-
<input type="button" value="Enable It" onclick="enableRadio('demoRadio')">
-
</BODY>
-
</HTML>
-
Thanks and Regards
Ramanan Kalirajan
though this demo should work, it is not a solution to the question.
there are some questions, that should be answered beforehand.
mainly, your code does not match your description in any way:
- are you using checkboxes (as in the description) or radio buttons (as in the code)?
- do you want to rate it with a button (as in the description) or via link (as in the code)?
- your test function’s parameter is used nowhere
- should the radios be grouped (aka same name)? Standardista’s corner: - <input type="radio" name="demoRadio" id="demoRadio" disabled="disabled"/>
should be - <INPUT type="radio" name="demoRadio" id="demoRadio" disabled>
in HTML 4.01 (although it is not treated as error)
as a general rule of thumb, write your code consequently in one style, e.g. all tag names upper case and all attribute names lowercase. makes up for a better reading experience (especially for those people, who shall have a look at your code later)
1)- are you using checkboxes (as in the description) or radio buttons (as in the code)?
2)- do you want to rate it with a button (as in the description) or via link (as in the code)?
3)- your test function’s parameter is used nowhere
4)- should the radios be grouped (aka same name)?
1) sorry for that error its radio buttons that i am using.
2) once he clicks on link/button the disabled property must get enabled . well it is a link as in the code.
3)sorry i had hardcoded the values in the test function to check the function
4) yeah a set of 10 radio buttons in a same row with same name .
here is an improved version of ma code - for($i = 1; $i <= 15 ; $i++){
-
for($k = 1; $k <= 10 ; $k++){
-
$myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."' value='". $k ."' disabled='true' $chk title='". $k." out of 10 ' />";
-
}
-
}
-
$myresult .= "<a href='#' id=\"rate-it\" onclick=\"test('rating".$i."');\">Rate It</a>";
-
-
<script type='text/javascript'>
-
function test(name){
-
-
//for (i=1; i<=10; i++){
-
// document.getElementById(name[i]).disabled=false; // tried this with the for loop..but error console gave an error like document.getElementById(name[i]) is NULL
-
document.getElementById(name).disabled=false;
-
//}
-
-
alert(name);
-
}
-
</script>
but still the enabling of the radio buttons is not working !
@pradeepjain - $myresult .= "<a href='#' id=\"rate-it\" onclick=\"test('rating".$i."');\">Rate It</a>";
In the above code "$i" is out of the loop. Where "i" is the loop index. Try to give this inside the loop or change the logic. As the "i" variable is holding juck data, it is not working for you.
@Dormilich
Attribute Minimization is not a good practice in XHTML 1.0. Is it ok to give like that. I will follow the code standards - all tag names upper case and all attribute names lowercase. Thanks for the information.
Thanks and Regards
Ramanan Kalirajan
-
for($i = 1; $i <= 15 ; $i++){
-
for($k = 1; $k <= 10 ; $k++){
-
$myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."' value='". $k ."' disabled='true' $chk title='". $k." out of 10 ' />";
-
}
-
$myresult .= "<a href='#' id=\"rate-it\" onclick=\"test('rating".$i."');\">Rate It</a>";
-
}
-
-
-
<script type='text/javascript'>
-
function test(name){
-
-
//for (i=1; i<=10; i++){
-
// document.getElementById(name[i]).disabled=false; // tried this with the for loop..but error console gave an error like document.getElementById(name[i]) is NULL
-
document.getElementById(name).disabled=false;
-
//}
-
-
alert(name);
-
}
-
</script>
sorry for ma error..i wrote the code by hand over here so that cane out of the for loop. but then also its not working . in the javascript i have shown a for loop thing which i tried earlier but it gave the error which i have given over there .
@pradeepjain
one of your core problems is, that you use multiple IDs, where they should be unique.
@RamananKalirajan
I was not talking about XHTML (because hardly anyone really uses it). if you were to use XHTML and to use the XML parser (most people use the HTML parser), you’d be prompted with every mistake.
i will tell u the exact requirement .
each row will have 10 radio buttons in which only 1 can be clicked at 1 time . so like this there will be 7 rows like this . each row of radio buttons have a unique ID like rating1..rating7 . so when i click on a rate-it link on each row tht row disabled property must get cancelled and the radio buttons must get enabled .
hope i made the concept clear and logic is correct also!!
each row of radio buttons have a unique ID like rating1..rating7
this is where your code fails.
you mean to say each radio button should have a diff id like rating11,rating12 for 1st row and rating21,rating22 for second row!!
jepp, as demanded by the DTD.
okie i did that and it worked ,, i tried to apply some jquery to it .. when its applied it stops working . but without the jquery it works f9! - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
<HTML>
-
<HEAD>
-
<TITLE> New Document </TITLE>
-
<META NAME="Generator" CONTENT="EditPlus">
-
<META NAME="Author" CONTENT="">
-
<META NAME="Keywords" CONTENT="">
-
<META NAME="Description" CONTENT="">
-
<script src="jquery.js" type="text/javascript" language="javascript"></script>
-
<script src="jquery.rating.js" type="text/javascript" language="javascript"></script>
-
<link href="jquery.rating.css" type="text/css" rel="stylesheet"/>
-
-
<script type="text/javascript">
-
function test(name)
-
{
-
alert(name);
-
for (k=1; k<=10; k++){
-
document.getElementById(name+k).disabled=false;
-
}
-
}
-
</script>
-
</HEAD>
-
-
<BODY>
-
<?php
-
for($i = 1; $i <= 15 ; $i++){
-
for($k = 1; $k <= 10 ; $k++){
-
$myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."".$k."' value='". $k ."' disabled='true' $chk title='". $k." out of 10 ' />";
-
}
-
$myresult .= "<a href='#' id=\"rate-it\" onclick=\"test('rating".$i."');\">Rate It</a><br/>";
-
}
-
echo $myresult;
-
?>
-
</BODY>
-
</HTML>
and the jquery.rating.js, jquery.rating.css are taken form the below site . http://www.fyneworks.com/jquery/star.../#tab-Overview
is there no solution for this or has no1 looked at this problem?
my problem is, that I don’t know jQuery.
some suggestions for what might be causing problems here.. bcos with out jquery everything works very well. but as soon as jquery is applied and radio buttons are replaced with stars it stops working :I(
I think your code works as intended…
… only that your stars are no radio buttons.
PS. check out the demo page with FireBug, you will see, that all radio buttons are hidden and instead some divs are visible. thus your radio buttons are disabled, but it doesn’t matter.
PPS. what an ‘obvious’ error, *sigh*
all tag names upper case and all attribute names lowercase.
Actually, tag and attribute names are case insensitive in HTML and, nowadays, lowercase is most used.
@Dormilich
you mean to say that the button thing will not work ! no other work around for this?
the button thing will work, only it doesn’t matter, because the buttons are invisible. to do anything on the stars, you have to meddle with the plugin.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Manatee |
last post by:
Hi group. I have exactly one external, alternate stylesheet that I want
to enable or disable by form controls, on one page only (not saved
across pages).
I used:
<link rel="alternate...
|
by: hortoristic |
last post by:
We are using JavaScript to Enable/Disable certain fields on web pages
based on business rules.
A simple example is if when using an option type tag, and the two
options are Yes and No. If YES...
|
by: teddy.am |
last post by:
Guys,
I have a set of 6 radio buttons, infront of each one there's a textbox
....
i need all textboxes disabled .... once one of the radio buttons is
selected, the texbox infront of it will be...
|
by: Kevin |
last post by:
I've been looking all over and I can't seem to find what ought to be
simple.
I need to disable a drop down when a checkbox is checked, and enable it
when same checkbox is unchecked.
I've...
|
by: scanreg |
last post by:
My form needs to (1) direct to specified URLs based on a combination of form selections and (2) enable/disable form features based on selections within the form
FORM
Radio 1
- A
- B
- C
...
|
by: Brandon McCombs |
last post by:
Hello,
I have a form that contains a listview on the left side and a column of
buttons on the right side. Only some of the buttons do I want enabled
all the time. The other buttons should be...
|
by: Pietro |
last post by:
Hi all,
First of all I'd like to thank you very very much ,as finally after many years of searching,I could find a code to disable/enable the shift key,but actually i cannot use the code as I'm...
|
by: sumanbangladesh |
last post by:
Hi
I have a page with 3 radio butons. If I select a specific one,then I like to view some other radio buttons otherwise the other radio buttons will be remain disabled or invisible.
I am very...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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
| |