473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

small jquery problem

pradeepjain
563 512MB
i am building a select based on the values in a text box .
like

Expand|Select|Wrap|Line Numbers
  1. $("#pincode").change(function(){
  2. $.post("doctor_search.php",{ pincode:$("#pincode").val()} ,function(data){
  3. $("#suggestions").html(data);
  4. });
  5.     });
when ever a error occurs when the form is submitted the select does not work as ajax is a change function . how to say to jquery tht do it if the value in the text box is not null also i.e trigger a event ??
Nov 24 '09 #1
11 1648
acoder
16,027 Expert Mod 8TB
Why not add a simple if condition which checks the value? If it's not empty. the request is made.
Nov 30 '09 #2
pradeepjain
563 512MB
hmm..yeah i thought of same logic..but i cld not write the if condition in jquery !! i am new to it !plzz can u show me the code !!only if condition?
Nov 30 '09 #3
acoder
16,027 Expert Mod 8TB
Why not use regular JavaScript, except perhaps to reference an element? E.g.
Expand|Select|Wrap|Line Numbers
  1. if ($("#pincode").val() != "") {
Nov 30 '09 #4
pradeepjain
563 512MB
its something like this rite

Expand|Select|Wrap|Line Numbers
  1. if ($("#pincode").val() != "") {
  2. $("#pincode").change(function(){
  3. $.post("doctor_search.php",{ pincode:$("#pincode").val()} ,function(data){
  4. $("#suggestions").html(data);
  5. });
  6.     });
  7. }

I had written that code earlier only ! but did not work ! so i thought the code was wrong ! anyways will give it a try again and get back to you. thank you :)
Dec 1 '09 #5
acoder
16,027 Expert Mod 8TB
No, that's not correct. Put the if statement inside the change function.
Dec 1 '09 #6
pradeepjain
563 512MB
but then error is other fields are discovered and errors are displayed again bcos of the
Expand|Select|Wrap|Line Numbers
  1. .change
i need to change the value in the pincode field for the jquery event to happen !!
Dec 1 '09 #7
acoder
16,027 Expert Mod 8TB
So you want this to take place when the form is submitted even if there are errors?
Dec 1 '09 #8
pradeepjain
563 512MB
if the field has some value in it the event must be triggered !
Dec 1 '09 #9
acoder
16,027 Expert Mod 8TB
Yes, but when? When should the check be made that there's some text in the field?
Dec 1 '09 #10
pradeepjain
563 512MB
when the user fills out the form 1st time its all okie .he fills the pincode thing so .change will work there . but say when the form has some errors and the same page is displayed with errors then the .change will not happen so i wanted to check if value is there in pincode then trigger the event !
Dec 1 '09 #11
acoder
16,027 Expert Mod 8TB
When the same page is displayed with errors, is the page still the same (Ajax) or what it unloaded/reloaded?

I think it's best if you show the page where the problem occurs.
Dec 2 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Gale | last post by:
I'm working on something in jQuery with XPath What I want to do is: if checkbox is checked, set background color od label that contain input(checkbox) to red I have this code:...
1
by: DuaneMoraes | last post by:
A new book on jQuery, the powerful JavaScript library, has been announced by Packt In Learning jQuery, Karl Swedberg and Jonathan Chaffer, creators of the popular jQuery learning resource...
2
by: Darrel | last post by:
I'd like to use the jquery datepicker. I have a asp.net 1.1 application set up with forms authentication protecting an admin directory: <location path="admin"> <system.web> <authorization>...
1
by: mikeh3275 | last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to...
20
by: Aaron Gray | last post by:
There does not seem too be anyway to test if two jQuery references are the same element. Given :- ... <div id="1"></div .... Then :- alert( $("#1") == $("#1"))
26
by: RobG | last post by:
Do some of the regulars here need to re-think their (sometimes strident) opposition to libraries? Both Microsoft and Nokia have announced support for jQuery. It seems to have gained quite a bit...
2
by: souporpower | last post by:
Hi All I am trying to print some HTML using JQUERY. I am posting the code. I don't see the alert. It seems as though the function is not registered when the document is loaded. Can someone...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: metaphysics | last post by:
I am using a jQuery script called LocalScroll, and I have a quick problem that needs fixing. The demo for the script is here: jQuery.LocalScroll - Regular Demo, and the documentation is here: Ariel...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.