- Screen name: eventide
- About Me: I am currently freelancing as a web developer. My biggest hobby is amateur astronomy.
- Website:
- Linkedin Link:
eventide's Profile
30 Posts
59 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- 22-Apr-2013 11:09 AM
- Forum: Using jQuery Plugins
Here's my form:<form id="frmUpload" action="../scripts/upload.php" method="post" enctype="multipart/form-data"><div id="sermonInfo">File: <input type="file" id="uploadedFile" name="uploadedFile" class="error"><br><br>Title: <input type="text" id="title" name="sermonTitle" size="35" maxlength="100"></div></form><div id="uploadInfo"><div class="progress"><div class="statusBar" style="width: 0%;"></div><div class="percent">0%</div></div><div id="status"></div><br><div id="required">Only mp3 files are allowed!</div></div>And here's the JS I'm using:<script>$(function() {/** Upload*/// Reset validation and progress elementsvar formValid = true,percentVal = '0%';$('#uploadedFile, #title').removeClass('error');$('#status, #required').empty().removeClass();$('.statusBar').width(percentVal)$('.percent').html(percentVal);$('form').ajaxForm({beforeSend: function(e) {if (!ValidateUploadForm()) {formValid = false;console.log('validateuploadform returned false');} else {console.log('validateuploadform returned true');formValid = true;}console.log('in beforeSend. formValid: ' + formValid);if (!formValid) {return false;}},uploadProgress: function(event, position, total, percentComplete) {console.log('in uploadProgress function. formValid: ' + formValid);if (formValid) {var percentVal = percentComplete + '%';$('.statusBar').width(percentVal)$('.percent').html(percentVal);}},complete: function(xhr) {console.log('in complete function. formValid: ' + formValid);if (formValid) {console.log('xhr.responseText: ' + xhr.responseText);console.log('formValid: ' + formValid);if (xhr.responseText === 'success') {$('.statusBar').width('100%');$('.percent').html('100%');$('#status').html('Successfully uploaded the file.').addClass('successUpload');// Clear the formClearForm();} else if (xhr.responseText === 'fail') {$('#status').html('There was a problem uploading the file. Try again.<br>If the problem persists, contact your system administrator.').addClass('errorUpload');}}}}); // End Upload Status Bar});function ValidateUploadForm() {// Reset errors and clear message$('#uploadedFile, #title').removeClass('error');$('#required').empty();var result = true;title = $('#title').val(),fileName = $('#uploadedFile').val();extension = $('#uploadedFile').val().split('.').pop();if (fileName !== '' && extension !== 'mp3') {$('#uploadedFile').addClass('error');$('#required').html('Only mp3 files are allowed!');return false;} else if (fileName === '') {result = false;} else if (title === '') {$('#title').addClass('error');result = false;}console.log('returning ' + result + ' from the validateuploadform function');if (!result) { $('#required').html('All fields are required.'); }return result;}function ClearForm() {$('#uploadedFile, #title').val('').removeClass();}</script>As you can see, I'm using console output the keep an eye on what's going on.My problem is, if a file is selected, the file still uploads, whether formValid (in beforeSend) is true or false.I've tried adding preventDefault before `return false;`. I've also tried clearing the file input in the `if (!formValid) {}` block. As you can see, I've wrapped the `uploadProgress` and `complete` functions to check if formValid is false. If the console output in uploadProgress shows formValid to be **false**, the file still uploads.What am I missing here? How can I prevent the file upload if the validation fails?
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- I put together a page that shows what's happening.here. The dialog is a confirmation that an email was sent, so you'll need to fill out the form to get the dialog to pop up. (I wanted to retain as much as the original functionality as possible.)
As the title says, I generated a UI theme using Themeroller and the dialog I'm using is completely void of all styling. To the point that the dialog is complete transparent and all that shows is the text in the dialog and the unstyled close buttons.I tried both the compressed and un-compressed ui css and js files with no change.I'm using other UI features elsewhere in the same site (highlighting, etc), and they work fine.Is this an issue with the Themeroller generator or am I missing something?For now I can just display a label with a confirmation message, but I'd really like to use a dialog...
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 19-Feb-2013 04:36 PM
- Forum: Using jQuery
I need to insert several rows of data into a particular place from the success function of an $.ajax call to a PHP database query.
What follows is the result of a suggestion at StackOverflow and some of my own testing. Currently this only inserts the new table into the space of a single cell immediately after the target row.
- function GetActorsForSelectedMovie(movieID) {
- // $.ajax call gets rows from php script
- var row = $('#tblMovieList tbody tr').find('td input.chkDeleteMovie[value="' + movieID + '"]').parent().parent();
- var newRowTable = $('<table id="tblActorsForMovie"></table>');
- //$.each(data, function (index, element) {
- newRowTable.append('<td width="113px"></td><td>actorID: 12, name: Some Actor</td>');
- //});
- row.after(newRowTable.wrap('<tr id="actorsForMovie" /><td colspan="10" />'));
- }
What I need to do is insert a row that contains the json data from the php script after the row that has a checkbox with a value set to a specific movie ID.
As I said, the code above inserts a table after the target row, but what gets inserted is just a table, not a table wrapped in a set of <tr><td> tags to work with the "parent" row. You'll see what I mean if you follow the jsFiddle link at the bottom of this post.
The final structure of the row that is to be inserted should look something like this:
- <tr id="actorsForMovie">
- <td colspan="10"> <!-- There are 10 rows in the "parent" table -->
- <table>
- <tr>
- <td>
- [actor data]
- </td>
- </tr>
- <tr>
- <td>
- [actor data]
- </td>
- </tr>
- ... etc for additional rows/actors
- </table>
- </td>
- </tr>
I have created a jsFiddle for anyone to take a crack at helping me figure this out. No matter what I've tried, the inserted table 1) Never gets wrapped in the and tags to make it work with the "parent" table, and 2) the inserted table always only gets put in the area of the first cell in the rest of the table.
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 06-Feb-2013 09:03 AM
- Forum: Using jQuery
I have a table that is built in an $.ajax success function as a result of a PHP/MySQL database query. The output looks like this:- <table id="tblViewEditAllBranches">
- <thead>
- <tr>
- <th>
- <input type="submit" id="btnDeleteCheckedBranches" value="Delete" title="Delete Selected Branches" class="ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false">
- </th>
- <th>Branch Name</th>
- <th>URL</th>
- </tr>
- </thead>
- <tbody>
- <tr class="viewEditRow rowBorder">
- <td class="deleteBranch">
- <input type="checkbox" class="chkDeleteBranch" name="deleteBranches[]" value="1">
- <br>
- <input type="submit" class="cancelListEditBranch edit hideOnLoad" value="Cancel" title="Cancel editing this branch" style="display: none;">
- <br>
- <input type="submit" class="submitListEditBranch edit hideOnLoad" value="Save" title="Save the changes" style="display: none;">
- </td>
- <td class="viewEditBranchName">
- <label class="viewBranchName detailDisplay" style="display: inline;">Atlanta</label>
- <input type="text" class="edit editBox editName hideOnLoad" value="Atlanta" style="display: none;">
- <br>
- <br>
- <label id="lblBranchesListEditError" class="errorMsg" style="display: none;"></label>
- </td>
- <td class="viewEditBranchUrl">
- <label class="viewBranchUrl detailDisplay" style="display: inline;">georgia</label>
- <!--<label class="viewBranchUrl detailDisplay"><a href="http://someplace.com/georgia" class="branchDetailLink" title="Click to go the branch\'s web page">georgia</a></label>-->
- <input type="text" class="edit editBox editUrl hideOnLoad" value="georgia" style="display: none;">
- </td>
- </tr>
- <tr class="viewEditRow rowBorder">
- <td class="deleteBranch">
- <input type="checkbox" class="chkDeleteBranch" name="deleteBranches[]" value="2">
- <br>
- <input type="submit" class="cancelListEditBranch edit hideOnLoad" value="Cancel" title="Cancel editing this branch">
- <br>
- <input type="submit" class="submitListEditBranch edit hideOnLoad" value="Save" title="Save the changes">
- </td>
- <td class="viewEditBranchName">
- <label class="viewBranchName detailDisplay">Boston</label>
- <input type="text" class="edit editBox editName hideOnLoad" value="Boston">
- <br>
- <br>
- <label id="lblBranchesListEditError" class="errorMsg"></label>
- </td>
- <td class="viewEditBranchUrl">
- <label class="viewBranchUrl detailDisplay">massachusetts</label>
- <!--<label class="viewBranchUrl detailDisplay"><a href="http://someplace.com/massachusetts" class="branchDetailLink" title="Click to go the branch\'s web page">massachusetts</a></label>-->
- <input type="text" class="edit editBox editUrl hideOnLoad" value="massachusetts">
- </td>
- </tr>
- </tbody>
- </table>
- $('#tblViewEditAllBranches').on('click', 'tr', function(e) {
- // Put text of labels into textboxes
- $(this).find('td').each(function() {
- $(this).find('.editBox').val($(this).find('.detailDisplay').text());
- });
- // Clear errors
- $('#tblViewEditAllBranches tr').find('#lblBranchesListEditError').text('');
- // Hide edit elements in other rows and labels in clicked row
- $('#tblViewEditAllBranches tr').not(this).find('.edit').fadeOut(200);
- $('label', this).fadeOut(200);
- // Show labels in other rows and edit elements in clicked row
- $('#tblViewEditAllBranches tr').not(this).find('label').delay(200).fadeIn(200);
- $('.edit', this).delay(200).fadeIn(200);
- e.stopPropagation();
- });
Note the commented URL in the third column.I need to make it so that link can be clicked and load the URL, but NOT cause the row to go into "edit mode".I'm having a lot of trouble figuring out how to isolate the link in the code so it can behave the way I need it to.I'd really appreciate some suggestions on how to accomplish this! Thanks!____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 21-Jun-2011 12:14 PM
- Forum: Using jQuery
Using jQuery I am inserting rows into a table after a database insert. When the page loads the table is ordered alphabetically on a particular cell. When I insert a new row using jQuery I would like to be able to insert it alphabetically also.So for example I have a table with <tbody> elements similar to this (sorry about the code formatting - or lack thereof, but the insert code button isn't working!):<tbody>
<tr class="docRow" bgcolor="#EFE5D3" style="font-weight: bold; font-size: 1.1em;">
<td width="25px"><a class="docEditLink docAdminFormSubmit" name="38" href="#">Edit</a></td>
<td width="20px"><input type="checkbox" class="chkDeleteDocs" name="removeDocs[]" value="38" /></td>
<td>Document A</td>
<td>Description of Document A</td>
</tr>
<tr class="docClassesRow noClasses">
<td colspan="4">
<strong>No classes are currently associated with this document.</strong>
</td>
</tr>
</tbody>
<tbody>
<tr class="docRow" bgcolor="#EFE5D3" style="font-weight: bold; font-size: 1.1em;">
<td width="25px"><a class="docEditLink docAdminFormSubmit" name="35" href="#">Edit</a></td>
<td width="20px"><input type="checkbox" class="chkDeleteDocs" name="removeDocs[]" value="35" /></td>
<td>Document B</td>
<td>Description of Document B</td>
</tr>
<tr class="docClassesRow">
<td></td>
<td width="100px" align="right"><input type="checkbox" class="chkRemoveClasses" name="removeClasses[]" value="33-35" /></td>
<td width="200px">CLASS111</td>
<td width="600px">Description of CLASS101</td>
</tr>
<tr class="docClassesRow">
<td></td>
<td width="100px" align="right"><input type="checkbox" class="chkRemoveClasses" name="removeClasses[]" value="45-35" /></td>
<td width="200px">CLASS333</td>
<td width="600px">Description of CLASS333</td>
</tr>
</tbody>
<tbody>
<tr class="docRow" bgcolor="#EFE5D3" style="font-weight: bold; font-size: 1.1em;">
<td width="25px"><a class="docEditLink docAdminFormSubmit" name="46" href="#">Edit</a></td>
<td width="20px"><input type="checkbox" class="chkDeleteDocs" name="removeDocs[]" value="46" /></td>
<td>Document D</td>
<td>Description of Document D</td>
</tr>
<tr class="docClassesRow noClasses">
<td colspan="4">
<strong>No classes are currently associated with this document.</strong>
</td>
</tr>
</tbody>Currently, when inserting a new class row to a given document I use the .append() function, and when inserting a new document I use .after().Using jQuery I want to be able to insert a class or document in alphabetical order on class number or document name (as appropriate for what's being inserted).So for instance I want to be able to insert a new <tbody> for Document C, or add a new class to Document B with a class number of CLASS222.How can I do this?____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 10-Jun-2011 11:45 AM
- Forum: Using jQuery
Seems to me this would be a fairly common situation (if not commonly asked and answered), but the posts I did find about this subject didn't seem to help me.Given this basic code:<form id="form" action=""><input id="submit1">
<input id="submit2"></form>In the form submit handler: $('#addClassAndDocs').submit(function(){ I need to be able to determine which button was clicked so I can perform the correct ajax call.One possible alternative I think is to handle the button events, rather than the form submission, but this thread told me to do it how I have it above. Due to that thread solution, the second button works, but at the time I posted that, I forgot about the first button!Thanks for any help!
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 09-Jun-2011 12:45 PM
- Forum: Using jQuery
I've attached a text file that includes a form and its associated jQuery code.Before I removed the action and post from the form (as commented in the code), the form worked fine using either submit button. But now the page only refreshes - the alert in the jQuery click event doesn't fire. I know that's not complete ajax functionality, I'm just trying to make sure I get to that point first...I'd appreciate it if someone could take a look at this and see if they can help me figure out what I'm missing.Thanks!
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng
- I would like to highlight the changes a user makes to a table. The changes are made in a dialog box, which is closed upon successful execution of a php script. The dialog closed fine until I added the following "highlight" effect to the text the user changed.success: function(response) {
if (response == 'success') {
// Populate the table row with the new class number and/or name
row.find('td:last').text(className).prev().text(classNumber);
var classNumberTD = row.find('td:last').prev();
var classNameTD = row.find('td:last');
// Highlight any changes the user made
if (classNumber != origClassNumber) {
classNumberTD.text().effect('highlight', { color: '#A04A56'}, 1500);
}
if (className != origClassName) {
classNameTD.text().effect('highlight', { color: '#A04A56'}, 1500);
}
// Find and update the class number/name in the dropdown as well
$('#classesList option[value="' + classEditID + '"]').text(classNumber + ' - ' + className);
$('#classEditDialog').dialog('close');
}
}
When I comment out only the two effect lines (leaving the "if" conditions there) the dialog closes normally.When I first added the highlight effect, I just chained it on to the end of the row.find... line that actually changes the td's text. That only highlighted the classNumber td tag, of course, and that's not a good solution, obviously, but the dialog did close in that case. Could it have something to do with the fact that I'm selecting the text when it doesn't work?Also, I thought, "Fine, since it seems the highlighting is breaking the dialog close line, then I'll close the dialog before the highlighting!" The dialog did close, but then the animation didn't work! Ah well. I tried...Thanks for anyone's help!P.S. I tried to add the code using the editor's html button, but for some reason it didn't work...
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 08-Jun-2011 01:14 PM
- Forum: Using jQuery
I would like to allow the user to be able to use the Enter key in lieu of the submit button on a page that has several forms.I'm assuming that to accomplish that I need to detect which form's elements are being edited (have focus?) and programmatically fire the submit button's action for that form.How do I do something like that?Thanks for anyone's help!
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- I am trying to implement jquery validation for a form that uses ajax. I also have a form on the same page whose validation works fine, but doesn't use ajax (uses action="process.php").After much "fiddling around" with the html, jquery and css, the best I can figure is that for some reason the click event code for the ajax-driven form is somehow breaking the validation.Here is what the working form looks like on submit with both inputs blank:And here is what the ajax-driven form looks like on submit with the inputs blank:I've attached the forms html and css, and the jquery code for you to look at (there was just too much to paste into here).I need to get this figured out because I plan on adding ajax to the working validation form and other forms on the site as well!I'd appreciate any help anyone can offer!
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmngAttachments- Forms HTML and CSS.pdf
- Size: 63.75 KB Downloads: 1785
- jQuery.pdf
- Size: 48.58 KB Downloads: 1755
- I have an ajax-updated form that uses event.preventDefault(). My problem is that as is, it works in every browser except IE9 (haven't tested earlier versions of IE). So after doing some research I added "event" to the function call:
- $('#submitDocEdit').click(function(event) {
And that fixed it for IE.However, now it doesn't work in Firefox 4!Is there a solution that works for all browsers? I'm using jQuery v1.6.1.____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- Hi, allI am (finally) successfully calling and running a php script using $.ajax() and now I need to update a table row as a result of that.In the ajax I have these variables for the updated row: docID, docName, docDescription. Since the docID is used elsewhere on the page, I'll need to start with the table id, which is #docsTable.The rows that I need to update look like this:
- <tr bgcolor="#EFE5D3" style="font-weight: bold;">
- <td width="25px"><a class="docEditLink" name="33" href="#">Edit</a></td>
- <td width="20px"><input type="checkbox" name="removeDocs[]" value="33" /></td>
- <td>Document Name</td>
- <td>Document Description</td>
- </tr>
The name attribute is the docID, so that is unique within that table, for that document.So, my question is, how can I build a selector that will allow me to change the 3rd and 4th <td> tags with document name and document description, respectively?Thanks!(While I'm waiting for an answer, I'll be trying to figure this out, too)____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- I'm just figuring out how to use $.ajax for the first time and I have a question specific to how I need to implement ajax.I have a table that is dynamically built in php from a database. The user can click on an "Edit" link that is in each line/row in the table. When they do, a UI dialog pops up with the information from the line the user clicked on. When the user clicks the Submit button in the dialog box, $.ajax will send the info to a server-side script that will process the edited data.I haven't yet implemented the above yet, but I have a pretty good grip on how to do what I have described above.My question lies in how to refresh the table to reflect the changes the user made in the dialog. This is AJAX, so I shouldn't have to reload the whole page - I'd imagine at the most the whole table. How do I do this?Thanks for anyone's help!
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 25-May-2011 09:23 AM
- Forum: Using jQuery
Hi, allI'm just now trying to get my head around AJAX in general and jQuery's AJAX specifically.I have a table that is generated from php/mysql. A sample of the rendered page can be seen here. I've also attached a text document with the php code that generates the page.What I'm trying to do is, when a user clicks on one of the edit buttons, I want to open a jQuery UI Dialog popup and populate a form with the current information for the class the user clicked on. Then, after the user clicks on a Submit button (and some basic validation), jQuery's ajax() sends the data for processing to a php script. Upon successfully processing the changes to the class I want to close the Dialog popup and show the changes in the table on the main page.The two things I don't understand how to do:1) Populate the Dialog's form with the information for the specific class the user clicked on, and2) Display the changes to the edited class after the script processes and the popup is closed.I'd appreciate any help in figuring out how to accomplish these things!Thanks in advance.
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmngAttachments- adminClasses_PHPcode.txt
- Size: 9.72 KB Downloads: 1705
- 27-Apr-2011 10:47 PM
- Forum: Using jQuery UI
Hi, all
I have UI Accordion set up on a page similar to this:- <div id="accordion">
<h3><a href="#"><input type="checkbox" name="deleteDocs[]" value="' . $rowDocs['docID'] . '" /> Class 1</a></h3>
<div>
<p>This is a document for the class.</p>
</div>
<h3><a href="#"><input type="checkbox" name="deleteDocs[]" value="' . $rowDocs['docID'] . '" /> Class 2</a></h3>
<div>
<p>This is a document for the class.</p>
<p>This is another document for the class.</p>
</div>
</div>
Along with the standard UI Accordion functionality I've added this:- $( "#accordion" ).accordion({
collapsible: true,
active: false,
autoHeight: false
});
I currently have this code to try to get that to happen:- $('#accordion h3')
.hover(function() {
$(this).toggleClass('hover').css('cursor', 'pointer');})
.next().click(function() {
$(this).parent().next().toggle();});
So, can anyone offer some help on getting this to work as I described?
Thanks!
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 18-Feb-2011 01:07 PM
- Forum: Using jQuery
Hi, all
I have the following code that works fine (except the show/hide animation for the rows is proving to be a pain to get working):- $('tr.docRow')
- .hover(function() {
- $(this).toggleClass('hover').css('cursor', 'pointer');
- })
- .click(function() {
- // Show and hide the row after the row that was clicked on
- $(this).next().toggle();
- });
In the table this is for, I have a checkbox in the first cell in the row the user hovers and clicks on to expand the following row. I am trying to make it so that clicking the checkbox doesn't trigger the jQuery toggling action.
Here is a sample row in the table this is for. The complete row below is what the user clicks on, and the row after that (class="docClassesRow") is what is expanded on clicking the above row- <tr class="docRow" bgcolor="#E7DDCC">
- <td align="center"><input type="checkbox" class="chkDeleteDoc" name="deleteDocs[]" value="7" /></td>
- <td>Document 1</td>
- <td>The first document in the list of items the user can see</td>
- </tr>
- <tr class="docClassesRow" bgcolor="#E7DDCC">
- <td>...
- $('tr.docRow:not(:first-child)')
What am I missing/doing wrong?
Thanks for anyone's help!
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- Hi, all
You can see here a sample of what I'm working on.
If you click on the second row you'll notice that the text doesn't change, but clicking on the first row changes that row's text.
I'm trying to make it so when you click the Edit Class link the text in that row gets changed, but as my selector is now it always selects the first table row - not the row clicked on.
I know my selector isn't quite right anyway (".parent().parent().child()"), so I need help with that anyway, but I'm sure getting that fixed will get my row-clicking issue fixed as well.
Thanks for anyone's help!
Mark
____________________________________
f u cn rd ths u cn gt a gd jb n prgrmmng- 13-Feb-2011 08:10 AM
- Forum: Using jQuery
Hi, all
This is the page I have the question on.
I finally figured out how to get the table rows to show and hide when its previous row is clicked (typical detail table setup). However, I can't get any animation to work properly.
Using the toggle() method shows and hides the desired row but they just "snap" open and closed. When I use the slideToggle() method there is a slight delay in the hiding and showing.
Adding some sort of animation parameter (slow, 400, etc) has no effect.
I'd appreciate it if someone could help me out here.
Thanks in advance!
f u cn rd ths u cn gt a gd jb n prgrmmng- 07-Feb-2011 01:36 PM
- Forum: Using jQuery Plugins
Hi,
I have a simple three-field form in a UI Dialog that, prior to POSTing, I need to validate using the jQuery Validation plugin.
Currently, if the user clicks the form's Submit button (the form's action for the PHP form handling is the page with the link that opens the Dialog in the first place) with a field not properly filled out, the Dialog just closes.
Clicking again on the link that opens the Dialog form will show the form with the error message(s) that the Validator generated on the previous click of the submit button.
How can I keep the Dialog open and prevent a POST until the form validates?
Thanks for anyone's help.
f u cn rd ths u cn gt a gd jb n prgrmmng- Hello all
I created a UI theme using ThemeRoller and am trying to use it in a website I am building. The accordion itself is functional, but no styling is being applied.
Here's a link to the problematic page: Test accordion. The folder's indexing is turned on, so you can verify my folder/file structure is correct is you so desire.
Obviously, the first thing to check when styling isn't working is the links to the stylesheets. I've checked, double-checked, and triple-checked both the css and js links and they all point to the files correctly (and the files are actually in the folders they're pointing to!). The doctype is XHTML 1.0 Transitional, so that shouldn't be a problem. Even though ThemeRoller bundles everything together, I even tried linking to the relevant core, widget, accordion, etc. css and js files, but that did nothing.
Now, there is one caveat to my page design: I'm building the individual accordion content sections (<div>s) from a php/mysql database query's while loop. Here's the full extent of the php code on the page:- <?php
// Connect to the db
include ('includes/dbConnect.php');
// Create the query to get the class IDs (for grouping each class's docs together in each div when the jQuery accordion is built)
// I just duplicated the query and added the GROUP BY clause, which results in returning the first record found for each class with at least one document assigned
$queryClasses = "SELECT c2.classID, c2.className, c2.classNumber, d2.docName, d2.docFileName, d2.docDescription
FROM classes c2
INNER JOIN classDocs cd2 ON c2.classID = cd2.classDocsClassID
INNER JOIN docs d2 ON cd2.classDocsDocID = d2.docID
GROUP BY c2.classID";
// Run the query
$resultClasses = @mysqli_query($dbc, $queryClasses);
// Get the number of returned rows from the classes query
$numClasses = mysqli_num_rows($resultClasses);
if ($numClasses > 0) {
// Query ran successfully and returned at least one row
// Open accordion container
echo '<div id="accordion" style="width: 400px; padding-left: 10px;">';
// Read records from the result set and build the jQuery accordion based on that
// Iterate through the $resultClasses set, creating a new <h3> & <div> pair for each class
while ($classesRow = mysqli_fetch_array($resultClasses, MYSQLI_ASSOC)) {
echo '<h3><a href="#">' . $classesRow['className'] . '</a></h3>
<!-- Open div containing class info and documents (this is repeated for each class) -->
<div style="padding-left: 10px;">
<p>' . $classesRow['className'] . '</p>
<p>' . $classesRow['classNumber'] . '</p>';
// Get the current row's classID to retrieve the current class's docs in the following query
$classID = $classesRow['classID'];
// Build the query to get the current class's docs
$queryDocs = "SELECT c.classID, d.docID, d.docName, d.docDescription, d.docFileName
FROM docs d
INNER JOIN classDocs cd ON d.docID = cd.classDocsDocID
INNER JOIN classes c ON cd.classDocsClassID = c.classID
WHERE c.classID = $classID";
// Run the query
$resultDocs = @mysqli_query($dbc, $queryDocs);
// Iterate through the result set and output each document's information and a link button to its file
while ($docsRow = mysqli_fetch_array($resultDocs, MYSQLI_ASSOC)) {
echo'<hr style="width: 350px; margin-left: 0px;" />
<p>Document Name: ' . $docsRow['docName'] . '</p>
<p>Description: ' . $docsRow['docDescription'] . '</p>
<p><input type="button" value="Download File" onClick="window.location.href=\'documents/' . $docsRow['docFileName'] . '\'" /></p>';
} // Close the documents While loop
// Close div containing class info & docs
echo '</div>
';
} // End of individual class's WHILE loop
// Close the accordion container
echo '</div>';
}
else {
// No records returned
// Message to Web page
echo '<p class="errors">Didn\'t find any classes. Please contact the site administrator.</p>';
// Debugging message
echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $query . '</p>';
}
?>
Any help will be greatly appreciated!- 24-Jun-2010 05:03 PM
- Forum: Using jQuery
Hi, all
I have a standard menu structured with an unordered list. Some of the items in the menu have sub items, but are not themselves links. Here's an example:- <ul id="mainMenu">
- <li><a href="">home</a></li>
- <li><a>services</a>
- <ul>
- <li><a href="">services 1</a></li>
- <li><a href="">services 2</a></li>
- </ul></li>
- ...
I want to change that so that when mousing-over anywhere in the <li> tag's area the cursor is an arrow pointer, but this should happen only for <li> elements that have an <a> tag with an attribute.
The below is what I have for two attempts:- // This was supposed to add the linkHover class to just the first level of the menu - but this styled not only all first level elements, but the sub-menu items as well...
- $('#mainMenu li a').hover(function() {
- $(this).addClass('linkHover');
- });
- // This is supposed to find only <a> tags in #mainMenu that have the href attribute - what it did was give me my "hand" back when mousing over the links, but didn't appear to add the linkHover class to the non-linking list items (they just got the text cursor)
- $('#mainMenu a').find('[href]').each(function(index){
$(this).addClass('linkHover');
});
How do I select a tag that does (or does not) have a particular attribute? In my case, I want to be able to select all <a> tags in #mainMenu that do not have the href attribute.- 24-Jun-2010 07:56 AM
- Forum: Using jQuery
Hi, all
I have a menu (see it here) that currently styles the anchor tag when an item is moused-over.
In that menu, the top items "services", "pricing", and "about" won't link to anything, so I want to be able to remove the <a> tags from those list items. The problem is I still want the background to change when the item is moused-over. But removing the links removes the styling, in effect.
As far as I know, :hover only works on <a> tags, so putting :hover on the li tag instead of the a tag doesn't work (I tried it), and I've tried styling the top-level li tag with jQuery using- this: $('#mainMenu li').hover( function() {
- $(this).css({background-color: "1C5B87"})
- }, function() {
- $(this).css({background-color: "2476B2"})
- }
I'd really appreciate it if someone could offer some coding suggestions on how to accomplish this!
Thanks- In the menu in this page I have four different methods (you can see them in the <script> tag on the pages) of indicating the current page in a menu. I downloaded these from various web pages after Googling "jQuery highlight current page".
None of the methods works. Is there something wrong with my selectors? Can anyone see why none of them are working?
Thanks for anyone's help!- 23-Jun-2010 01:35 PM
- Forum: Using jQuery
I have a mockup of a new menu I am building here. All of the css and javascript/jQuery code is on web page itself.
I just need to get two things changed and I'm done:
1)
The three middle items that have sub-menus, "services", "pricing", and "about" won't actually link to pages themselves. The CSS (I built this menu based on a web site's tutorial) is looking for the <a> tag to set the background color during a mouse-over. Since those list items don't actually link to a page, I want to remove the <a> tag from them, but keep the mouseover background coloring.
I can't figure out how to do that. I tried changing the existing CSS selectors by removing the a:hover and then adding a line in my jQuery code to add a background-color style on hover, but that only changed the <a>'s text (using parent() ) didn't work either).
How can I remove those three <a> tags but keep the mouseover background styling effect?
2)
You'll notice I'm using fadeIn() for the mouseover event. I would like to use fadeOut() as well, but adding that to my existing mouseout line does nothing. How can I use fadeOut() with what I have?
Thanks for anyone's help!- 08-Jun-2010 02:31 PM
- Forum: Using jQuery
Hi, all
I'm trying to do what the post title says and I ran across this article whose title is exactly what I'm trying to do, so I gave it a shot, but it didn't work.
I'm just learning jQuery so I've gone over the documentation on selectors, and adding and removing classes and attributes. As far as I can tell I'm selecting the tags and setting the classes/attributes correctly.
On one page I've got some images as links in a table:- <td><a href="http://www.example.com"><img src="images/exampleSite.jpg" /></a></td>
Now, in my external stylesheet I have these two classes defined:- #content a { border-bottom: dashed 1px #000000; }
#content a:hover { border-bottom: solid 1px #2476B2; }
And in a linked js file I'm trying to remove the border as follows:- $("a[img$='.jpg']").attr( 'border-bottom', 'none' ).attr( 'text-decoration', 'none');
But it's not removing the border and I can't figure out why.
I'd appreciate it if someone could offer some help/suggestions.
Thanks in advance.- «Prev
- Next »
- <?php
Moderate user : eventide
© 2012 jQuery Foundation
Sponsored by
and others.



