aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes radio buttons and buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "radio buttons and buttons" Watch "radio buttons and buttons" New topic
Author

radio buttons and buttons

Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Guys,

Well i have a littel issue thats bugging me now, Ok here goes

I have a form which has a number of radio buttons, then I have some normal buttons that are sumbit and reset.

What I want to do in my JSP is when one radio button is selected to enable the submit/reset, and not before.

How do i do this.

code snippet below:

The loop creates a varible number of radio buttons, i then have one submit, and one reset button each, which need enabling only when I have selected one of the radio buttons.

LOOP--------->
<tr>
<td width="6%" bordercolor="#C0C0C0" style="border-bottom:1px solid #C0C0C0; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; " align="center" height="17">
<form method="POST" onclick action ="withdraw.jsp?&username=<%= username%>&paper_id=<%=paper_id%>&paper_title=<%=paper_title%>&userType=<%=userType%>">
<p align="center">
<input type="radio" value="V1" name="R1"> </p>
</td>
<td width="8%" bordercolor="#C0C0C0" style="padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; border-bottom-style:solid; border-bottom-width:1px" align="center" height="17">
<p><font face="Arial"><%= paper_id %></font></p>
</td>
<td width="10%" bordercolor="#C0C0C0" style="padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; border-bottom-style:solid; border-bottom-width:1px" align="center" height="17">
<p><font face="Arial"><%= version %></font></p>
</td>
<td width="33%" bordercolor="#C0C0C0" style="padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; border-bottom-style:solid; border-bottom-width:1px" align="center" height="17">
<p align="left"><font face="Arial"><%=paper_title %></font></p>
</td>
<td width="13%" bordercolor="#C0C0C0" style="padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; border-bottom-style:solid; border-bottom-width:1px" align="center" height="17">
<p align="center"><font face="Arial"><%= paper_status %></font></p>
</td>
<td width="15%" bordercolor="#C0C0C0" style="padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; border-bottom-style:solid; border-bottom-width:1px" align="center" height="17">
<font face="Arial"><%= date_submitted %></font> </td>
<td width="7%" bordercolor="#C0C0C0" style="padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; border-bottom-style:solid; border-bottom-width:1px" align="center" height="17">
<p><font face="Arial"><%=descision %></font></p>
</td>
</tr>
<--------LOOP

</table>
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"><p>
</p>
</form>

Thanks in advance
Zein
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

You'll need to use Javascript to accomplish that.

Moved to the HTML/Javascript forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
onclick="document.formName.submitName.disabled = false;document.formName.resetName.disabled = false;"

Note:You need to learn how to usee CSS classes to make your code smaller.

Eric
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
The above doesnt seem to work.

See I have a JSP page, the form method is as below with the enabling code [that u posted above]

form method="POST" "on click="document.formName.submitName.disabled = false;document.formName.resetName.disabled = false;" action ="withdraw.jsp?&username=%= username%....

This form is inside a loop, soo it repeats x amount of times [creates a table].

At the bottom of the table we have a submit and reset button, [ that i can only manage to disable when adding the code disable="disabled"]

The tag reads as:

input type="submit" value="Submit" name="B1"
input type="reset" value="Reset" name="B2"

The error that comes up is
document.formName.submitName.disabled is null or not an object

Where am I going wrong?

Thanks in advance.
Zein

PS: had to change on click so i can post.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
the onclick does not go on the form tag.....
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
first of all give a name to your form tag.

you will need to put your on click in your radio tag.


and if you want to enable the buttons dont you think they should be disabled first???



try the above changes and it should work fine.
let us know.


Life called,so here I am.<br />Cheers<br />Niki.:-)
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Cheers nikki for the above,

Ive tried it what you reccommended, but havent made any headway.

This is my code below



So now i have the java script in the radio button tag, the buttons at the bottom disabled, what could be the problem? Logically it should work?



Regards
Zein
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Forgot to metion the symtoms and error.

Ok the error comes up as submit.forname is null, as described in the 1st post.

Also the buttons (submit and reset are always disabled), regradless of clicks on the radio buttons.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
you do not have a name on your form:

<form namne="Form1" ......


then with the code it would be

document.Form1.submit.disabled = false;

Plus you have no name on your reset element.

Eric
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
zein

eric is correct.

you need to give a name to the form.
this is done to access the form elements.
you give the name in the form tag

then using this name you access the html elements by
document.FORM1.submit.disabled,etc.

just check your form tag and you will find out that it is misssing the name attribute.
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Hmmmmn, still a little baffeld guys,

Ive done as you have said in the above posts, stil no luck though.

Here goes my form is as

So ive given it a name now.

The radio button is as



and the buttons are as:



I get the error "Object does not support this property or method"

What have i done wrong, or left out now? (full form code below)

Thanks in advance
Zein


Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
use the button name, not its type.
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
1)as eric said use the button name instead of the button type.


2) in your button tag you can just write disabled as standalone.



after this i think it should start working.
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Cheers Guys

Works like a charm. Thank you soo much Eric and Nikki (and anyone else ive forgot to mention)

Much appreciated

Zein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: radio buttons and buttons
 
Similar Threads
What American Accent Do You Have?
Why this problem???
problem in running a servlet
JSP Help Regarding the Radio Button
Page displaying in IE6 and older versions but not in Higher versions, chrome and firefox also.