/    Sign up×
Community /Pin to ProfileBookmark

ID not getting submitted

Hello all,

I have been working on the same issue for about a week now with people in other forums and thought I would give this one a shot.

Category ID Name Description Parent ID
35 Books 29
36 RSS Feeds 33
37 Webinars 29

Add Sub-Category
Sub-Category Name:
Description:
Location:

This is the basic layout of my page, the Location is a list of categories that a user can choose from that uses Javascript to make breadcrumbs. That way when a user clicks on a category, the name of the category pops up on top of the location box so they know they chose the right one. This category list is supposed to post the ID to the ParentID field in the gridview that I included at the top of the page.

This site in in ASP.net 4 using VB by the way.

Here is the javascript code:

$(document).ready(function () {
// Live update product name while typing
$(‘#txtNewCategoryName’).keyup(function () {
var CategoryName = $(‘#txtNewCategoryName’).val();
$(‘span#NewCategory’).html(“”);
$(‘span#NewCategory’).html(CategoryName);
});
// Load root categories
GetSubCategories(‘lbxCategories0’, ‘all’)
$(‘select[id^=”lbxCategories”]’).live(‘change’, function () {
var id = $(this).attr(‘id’);
var CategoryID = $(‘select#’ + id + ‘ option:selected’).attr(‘value’);
GetSubCategories(id, CategoryID);
});
function GetSubCategories(id, CategoryID) {
var SelectClicked = id.substring(13);
var NextID = (SelectClicked) * 1 + 1; //Multiply by 1 to force the variable to be read as integer (add vs concatenate) [url]http://www.webmasterworld.com/javascript/3371552.htm[/url]
$(‘select[id=”‘ + id + ‘”] ~ select’).remove();
$(‘select[id=”‘ + id + ‘”] ~ span.CategoryChosen’).remove();
$.ajax({
type: “POST”,
data: “{‘CategoryID’ : ‘” + CategoryID + “‘}”,
url: “WebService.asmx/GetSubCategories”,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
success: function (json) {
if (json.d != “”) {
var NewSelectList = “<select size=’4′ id=’lbxCategories” + NextID + “‘>”
var Options = “”;
$.each(json.d, function (index, CategoryArray) {
var NewCategoryID = CategoryArray.CategoryID;
var NewCategoryName = CategoryArray.CategoryName;
var ChildCount = CategoryArray.ChildCount;
var hasChildren = ” > “;
Options = Options + “<option value='” + NewCategoryID + “‘>” + NewCategoryName + hasChildren + “</option>”;
});
if (Options != “”) {
NewSelectList = NewSelectList + Options + “</select>”;
$(‘td#CategoryBoxes’).append(NewSelectList);
}

if (CategoryID != “all”) {
$(‘div#CategoryBreadcrumb span#Breadcrumb’).html(“”);
}
$(‘select[id^=”lbxCategories”] option:selected’).each(function () {

$(‘div#CategoryBreadcrumb span#Breadcrumb’).append($(this).html());

});
} else {
if (CategoryID != “all”) {
$(‘div#CategoryBreadcrumb span#Breadcrumb’).html(“”);
}
$(‘select[id^=”lbxCategories”] option:selected’).each(function () {

$(‘div#CategoryBreadcrumb span#Breadcrumb’).append($(this).html());

});
}
$(‘select[id^=”lbxCategories”] option#SelectedCategory’).removeAttr(“id”);
var totalSelectBoxes = $(‘select[id^=”lbxCategories”] option:selected’).size();
$(‘select[id=”lbxCategories’ + totalSelectBoxes + ‘”] option:selected’).attr(“id”, “SelectedCategory”);
var SelectedCategory = $(‘#SelectedCategory’).attr(“value”);
$(‘input[type=”hidden”]#txtCategoryID’).attr(‘value’, SelectedCategory);
},
error: function (e) {
}
});
}

});

Is there anything wrong with the code that isn’t allowing a ParentID value to get inserted? The ID that goes into the ParentID column is actually a CategoryID. I hope that is enough information so that no one gets confused about my problem.

Thank you in advance for your help!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @grinnellja spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...