Page 1 of 1
Radio button checked on dropdownlist change event
Posted: Sat Nov 22, 2014 11:20 am
by devd
hi,
I want to keep the checked radio button as checked on dropdownlist change event....How can i achieve this?
Re: Radio button checked on dropdownlist change event
Posted: Sat Nov 22, 2014 11:25 am
by Celauran
I'm not seeing how the two are connected. Changing the selected value of a set of radio buttons should have no effect on a select list and vice versa. That's default behaviour. Can you maybe show an example of what you're trying to achieve?
Re: Radio button checked on dropdownlist change event
Posted: Sat Nov 22, 2014 11:36 am
by devd
hi,
yes i will provide the code.
I have two radio button and one dropdown list in my page
<input type="radio" class="rd" name="rdcode" id="rdnew" value="1" />New Code :
<input type="radio" class="rd" name="rdcode" id="rdexist" value="2" checked="checked" />Existing Code:
<select id="ddlItem" name="ddlItem" tabindex="1" onChange="getItem(this.value);">
<option value="0" selected="selected">--Select Item--</option>
<option value="1" >Apple</option>.....</select>
When page loads my Existing code radio button is defaulty checked....Thats fine for me...
But when I select the first radio, ie radiobutton for New Code(rdnew) and then try to change the dropdownlist item,
the second radiobutton is again showing as checked.But I want to keep the' rdnew' radio button as checked instead of rdexist.
thank you
Re: Radio button checked on dropdownlist change event
Posted: Sat Nov 22, 2014 11:40 am
by Celauran
What is getItem? That looks to be where the problem lies.
Re: Radio button checked on dropdownlist change event
Posted: Sat Nov 22, 2014 11:43 am
by devd
No...that is another javascript function ....Eventhough i remove that function ....my problem exists.....
Re: Radio button checked on dropdownlist change event
Posted: Sat Nov 22, 2014 1:12 pm
by devd
hi,
can you have any suggestion for my problem ?
Re: Radio button checked on dropdownlist change event
Posted: Sat Nov 22, 2014 1:48 pm
by Celauran
I asked to see some code and you refused. What more do you want me to do? There's nothing in the code you have posted that explains that behaviour.
Re: Radio button checked on dropdownlist change event
Posted: Sun Nov 23, 2014 3:52 am
by devd
o.k....see i don't have any problem to display my code....But when checked i didn't find any probs with that getitem()..Thats why i written like that....o.k sir....
I will prove the getItem ()
function getItem(cid)
{
var id= cid;
window.location.href="item.php?cid="+id;
}
Re: Radio button checked on dropdownlist change event
Posted: Sun Nov 23, 2014 7:09 am
by Celauran
devd wrote:Code: Select all
window.location.href="item.php?cid="+id;
And there's the problem. You're reloading the page, which is resetting the form. What is it you're ultimately trying to do? I'm sure it can be accomplished differently.
Re: Radio button checked on dropdownlist change event
Posted: Sun Nov 23, 2014 1:20 pm
by devd
I want to load another dropdownlist with the first ddl change event...so how can I accomplish this differently...as am new to php I dont know whether I am writing the coding correctly
Re: Radio button checked on dropdownlist change event
Posted: Sun Nov 23, 2014 7:38 pm
by Celauran
Make an AJAX call to a PHP script that will run the query and return the results. Check out
jQuery.ajax