Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-01-2010, 05:04 PM   PM User | #1
1337hovie
New Coder

 
Join Date: Feb 2010
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
1337hovie is an unknown quantity at this point
Jquery logic help please!

Very new to jquery, i have a dropdown that changes what DIV's to show. but my problem is that the dropdowns will retain their value as i switch between divs. trying to clear values when the dropdown changes.

change divs onchage:
Quote:
$(document).ready(function(){
$('#3_form').hide();
$('#4_form').hide();
$('#axd_form').hide();
$('#ht_form').hide();
$("#thechoices").change(function(){
if(this.value == 'all')
{$("#boxes").children().show();}
else
{$("#" + this.value).show().siblings().hide();}
});

$("#thechoices").change();
});
This is what i have so far, i just need to check if the dropdown has been changed:
Quote:
$.fn.clearForm = function() {
return this.each(function() {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form')
return $(':input',this).clearForm();
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = '';
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
else if (tag == 'select')
this.selectedIndex = -1;
});
};

$(document).ready(function(){
function clearFields() {
// if ..check dropdown
$('.form3').clearForm();
// else if dropdown value
$('.form4').clearForm();//clear these fields
}

});
If you select form4, clear the other 2, same for other forms. OR just clear all div's (not entire form!) anything its changed. As long as these div's change, and rest of my form doesnt.

Advice, tutorials, suggestions, code snippets, ANYTHING WILL HELP!

Thanks again,
JT

Last edited by 1337hovie; 10-01-2010 at 05:11 PM..
1337hovie is offline   Reply With Quote
Old 10-01-2010, 05:08 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
You would do better to post this in the jQuery section of the forum. Ask a mod to move you over.

But if you run all your code together on one line it is very hard to read and a lot of people may not bother.
Philip M is offline   Reply With Quote
Old 10-01-2010, 05:09 PM   PM User | #3
1337hovie
New Coder

 
Join Date: Feb 2010
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
1337hovie is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
You would do better to post this in the jQuery section of the forum. Ask a mod to move you over.

But if you run all your code together on one line it is very hard to read and a lot of people may not bother.
Great point, thank you

I thought i was in the proper section, Yeah if someone can move this post - that'd be great. (i did a search for jquery on the main page, too - didnt see a jquery section).

is there a better tag? other than [code]?
1337hovie is offline   Reply With Quote
Old 10-01-2010, 05:23 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by 1337hovie View Post
Great point, thank you

I thought i was in the proper section, Yeah if someone can move this post - that'd be great. (i did a search for jquery on the main page, too - didnt see a jquery section).

is there a better tag? other than [code]?
Javascript Frameworks - Use this forum to get help on one of the popular JS frameworks, such as Prototype, jQuery, YUI etc.

You have put your code in quotes. You should use code and /code tags (in square brackets). Use the octothorpe # button on the toolbar.

Ask a mod (nicely) to move the post. It could be quite a time before one passes by this thread casually. You will find them listed at the bottom of the page.
Philip M is offline   Reply With Quote
Old 10-01-2010, 05:35 PM   PM User | #5
1337hovie
New Coder

 
Join Date: Feb 2010
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
1337hovie is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
Javascript Frameworks - Use this forum to get help on one of the popular JS frameworks, such as Prototype, jQuery, YUI etc.

You have put your code in quotes. You should use code and /code tags (in square brackets). Use the octothorpe # button on the toolbar.

Ask a mod (nicely) to move the post. It could be quite a time before one passes by this thread casually. You will find them listed at the bottom of the page.
Ok great thank you, i just Pm'd one. Hopefully he'll take care of it.

I do appreciate your time,
you wouldnt happen to know anything about jquery would ya? :P

seems like a simple request, to just add the logic into the JS. Totally new to jquery, at the mercy of kind forum communities!

Happy friday everybody!
Please help! :P

Jt
1337hovie is offline   Reply With Quote
Old 10-01-2010, 06:38 PM   PM User | #6
harbingerOTV
Senior Coder

 
Join Date: Jan 2005
Location: Memphis, TN
Posts: 1,765
Thanks: 8
Thanked 123 Times in 121 Posts
harbingerOTV will become famous soon enough
Can you post the HTML of the form?
__________________
Stop making things so hard on yourself.
i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis
harbingerOTV is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:09 PM.


Advertisement
Log in to turn off these ads.