Radio button checked on dropdownlist change event

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
devd
Forum Commoner
Posts: 25
Joined: Tue Nov 18, 2014 9:14 am

Radio button checked on dropdownlist change event

Post by devd »

hi,
I want to keep the checked radio button as checked on dropdownlist change event....How can i achieve this?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Radio button checked on dropdownlist change event

Post 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?
devd
Forum Commoner
Posts: 25
Joined: Tue Nov 18, 2014 9:14 am

Re: Radio button checked on dropdownlist change event

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Radio button checked on dropdownlist change event

Post by Celauran »

What is getItem? That looks to be where the problem lies.
devd
Forum Commoner
Posts: 25
Joined: Tue Nov 18, 2014 9:14 am

Re: Radio button checked on dropdownlist change event

Post by devd »

No...that is another javascript function ....Eventhough i remove that function ....my problem exists.....
devd
Forum Commoner
Posts: 25
Joined: Tue Nov 18, 2014 9:14 am

Re: Radio button checked on dropdownlist change event

Post by devd »

hi,
can you have any suggestion for my problem ?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Radio button checked on dropdownlist change event

Post 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.
devd
Forum Commoner
Posts: 25
Joined: Tue Nov 18, 2014 9:14 am

Re: Radio button checked on dropdownlist change event

Post 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;
}
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Radio button checked on dropdownlist change event

Post 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.
devd
Forum Commoner
Posts: 25
Joined: Tue Nov 18, 2014 9:14 am

Re: Radio button checked on dropdownlist change event

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Radio button checked on dropdownlist change event

Post by Celauran »

Make an AJAX call to a PHP script that will run the query and return the results. Check out jQuery.ajax
Post Reply