[jQuery] Select change, multiple selects

2009-02-26 Thread dwalls32

Hi everyone. I'm fairly new to jquery and I am kinda perplexed with
this issue.

I've got a page (dashboard.php) with 2 select boxes. The first select
box triggers the jquery script below, which populates the 2nd box with
values:

///

script type=text/javascript charset=utf-8
$(function(){
  $(select#startstate).change(function(){
alert($(this).val());//debug
$.getJSON(admin/startcities.php,{id: $(this).val(), ajax: 'true'},
function(j){
  var options = '';
  for (var i = 0; i  j.length; i++) {
options += 'option value=' + j[i].optionValue + '' + j
[i].optionDisplay + '/option';

  }
  $(select#startcity).html(options);
})
  })
})
/script

///

I take the results of those 2 select elements and submit them to the
same page via GET, changing the url to something like this:
dashboard.php?startstate=AKstartcity=ALEKNAGIK

I then grab the startstate value and see if a startcity elements has
been selected. If it is, then I pre-populate the city names and add
SELECTED to the one that was selected in the 2nd box. Here is the code
that typically makes up the 2nd select element:

///

select name=startcity id=startcity 

?
if($_GET['startstate'] == TRUE){
echo option value=\\ALL CITIES/option;
$q = SELECT DISTINCT cityname FROM areas WHERE stateabbr = '.$_GET
['startstate'].';
$result = $database-query($q);
while($row = mysql_fetch_array($result)){
echo option value='.$row['cityname'].';

if($row['cityname'] == $_GET['startcity']){
echo  SELECTED ;
}
echo ;
echo $row['cityname'];
echo /option;
}
}

?

/select

///

Ok, if you're still reading, the issue I have is that when I change
the #startstate select box, and the #startcity has been prepopulated,
Firefox ignores the change event. IE however registers it. I put an
alert for debugging right after the change event to make sure. I would
appreciate it if anyone has any ideas what I might have missed.

Thanks in advance!


[jQuery] Getting started with AJAX/Database multiple items per page

2009-01-01 Thread dwalls32

Hi All,

I am new to jQuery, and I'm unsure where to get started with what I am
working on. I've read AJAX tutorials but most deal with only 1 element
per page. Here is what I want to accomplish.

I've got a page which pulls records from a database and displays them
all on one page. There is a field in the database (either a 0 or 1)
which represents approved (0) or not approved (1). There is a link
next to each item that says i approve or i do not approve, and I
want the user to click this, have the database change, and
automatically change the link to the opposite state. I can do this for
1 item, but I am unsure how to handle this for multiple items on one
page. How should I attack handling the variables that update the
individual items?

Thanks in advance
Doug