• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

radio buttons and buttons

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to use Javascript to accomplish that.

Moved to the HTML/Javascript forum.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the onclick does not go on the form tag.....
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use the button name, not its type.
 
Niki Nono
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers Guys

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

Much appreciated

Zein
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic