very urgent...

S

saurabh

I have a form in which there are two types of control a) asp.net (3
radio button) b) html control (textbox).
On everytime page is load (postback or withoupostback) i want my code
to check which radio button is checked. If any of the first two radio
button is checked i want to set textbox value as "t" and in case 3rd
radio button is checked i want to set textbox value as "f"

This thing is not working :
if(radio1.checked==true)
textbox.text="t"

because textbox is an html control and not an asp.net control.....can
anybody tell me how to solve this issue???
 
B

Bipin

I think you can do this by javascript in client side code.
try writing the code inside <FORM> or make this as a function and call it
from Form_Onload.

<script language="Javascript>
if (form.getelimentid('radio1').checked == true ||
form.getelimentid('radio2').checked == true)
textboxt.text = 't';
else
textboxt.text = 'f';
endif
</script>

HTH
Bipin

<DIV>&quot;saurabh&quot; &lt;[email protected]&gt; wrote in message
 
P

Przemek Ptasznik

Bipin napisał(a):
I think you can do this by javascript in client side code.
try writing the code inside <FORM> or make this as a function and call
it from Form_Onload.

<script language="Javascript>
if (form.getelimentid('radio1').checked == true ||
form.getelimentid('radio2').checked == true)
textboxt.text = 't';
else
textboxt.text = 'f';
endif
</script>

this code doesn't seems to work.

You can do what you want to in two ways:
1) on the client-side (with javascript):
use "document.getElementById('radio1').checked" instead of
"form.getelimentid('radio1').checked"

2) on the server-side :
First you must convert textbox (actually html input element) into a
html server control. Just add to this element runat="server" and id
attributes.
Second - write event handler for radioButton event that will set
textBox's Text property.
 
S

saurabh

Hey still didnt get the solution...even this thing is not working...
getting the error "object required" at the line
"if(document.getElementById('rbupdated').checked==true ||
document.getElementById('rbmostused')==true)"....
It seems it is not able to identify the radio button rbupdated...also
it seems "checked" property is not thr, because whn i pressed
ctr+space baar after ('rbupdated') , I didnt get "checked " in the
list of available properties
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top