Click here to Skip to main content
15,887,135 members
Home / Discussions / Web Development
   

Web Development

 
QuestionMVC5 Slow File Upload Pin
#realJSOP26-Jan-18 9:27
mve#realJSOP26-Jan-18 9:27 
AnswerRe: MVC5 Slow File Upload Pin
malkovich19887-May-19 3:22
malkovich19887-May-19 3:22 
GeneralRe: MVC5 Slow File Upload Pin
#realJSOP7-May-19 4:03
mve#realJSOP7-May-19 4:03 
QuestionLinking database to a html page Pin
Member 1364494625-Jan-18 16:15
Member 1364494625-Jan-18 16:15 
AnswerRe: Linking database to a html page Pin
Richard MacCutchan25-Jan-18 22:31
mveRichard MacCutchan25-Jan-18 22:31 
GeneralRe: Linking database to a html page Pin
Valecia_cho8-Feb-18 14:50
Valecia_cho8-Feb-18 14:50 
GeneralRe: Linking database to a html page Pin
Richard MacCutchan8-Feb-18 22:33
mveRichard MacCutchan8-Feb-18 22:33 
QuestionPutting Data Onto HTML Using JavaScript Pin
Valecia_cho24-Jan-18 14:58
Valecia_cho24-Jan-18 14:58 
I'm trying to get some JavaScript to unpack some data using a JSON parse from a separate bit of PHP. Here's what that JSON parse looks like:

[{"ID":"0","Item":"A","Price":"100","Stock":"2214"}, {"ID":"1","Item":"B","Price":"100","Stock":"2214"}....to whatever]

Here's the Javascript that handles all of that:

JavaScript
txt += products[i].ID + ": " + products[i].Item + " \n" + "Price: " + products[i].Price + " \nStock availability: " + products[i].Stock + " \n\n";

$("#itemSelection").append($("<option></option>").text(products[i].Item  +"" + products[i].Price).val( products[i].Price ));


This is actually the body of a for loop. So that 1st line unravels the string of data from before and the next line then displays that on a HTML dropdown box. Of course it displays the item and the price, but the actual value of the selection in the background is just the price. Is there a way that the value of the selection can be both the name of the item and the price? Moreover, is there a more efficient way of doing this, since my method for getting the selected item from the drop box into a form is the next bit.

So as part of the aforementioned for loop, this just take that info and sticks it into an array:
JavaScript
sqlStockArr.push( new sqlStock(products[i].Item, products[i].Price) );


Everytime a user makes a selection, this next bit takes the text, value and position of the selection:

var a = $( "#itemSelection option:selected" ).text();
var b = $( "#itemSelection option:selected" ).val();
var c = $("#itemSelection option:selected").index();
var selArrItem = sqlStockArr[ c ].item;
	var selArrPrice = sqlStockArr[ c ].price;
	
	$( document ).ready( function(){
		$("#customerSelection").append($("<option></option>").text(a).val(b));
		
		selectedArr.push( new sqlStock(selArrItem, selArrPrice) );
	
		
		total += sqlStockArr[ c ].price;
		
		$("#printPrice").text(total);


Pretty sure I've just made a mess of this. Also please note that I've only included the main chunks of code. If it was part of a function or something, that's not really the issue. Anyways, what you can see is once something has been selected from the aforementioned itemSelection and put into the customerSelection using .text(a).val(b), it does the same kind of thing as before. Another array is made to handle all of that data. Again, is there a less messy way of doing things.

Real sorry if this is just a confusing pile of mess. If anyone can offer up some constructive critique, please go right ahead.
AnswerRe: Putting Data Onto HTML Using JavaScript Pin
Nathan Minier25-Jan-18 5:17
professionalNathan Minier25-Jan-18 5:17 
GeneralRe: Putting Data Onto HTML Using JavaScript Pin
Valecia_cho8-Feb-18 14:00
Valecia_cho8-Feb-18 14:00 
GeneralRe: Putting Data Onto HTML Using JavaScript Pin
Nathan Minier12-Feb-18 1:24
professionalNathan Minier12-Feb-18 1:24 
GeneralRe: Putting Data Onto HTML Using JavaScript Pin
Valecia_cho18-Feb-18 9:01
Valecia_cho18-Feb-18 9:01 
GeneralRe: Putting Data Onto HTML Using JavaScript Pin
Nathan Minier20-Feb-18 1:28
professionalNathan Minier20-Feb-18 1:28 
QuestionHow to start a job listing,directory,ad site? Pin
savedlema22-Jan-18 11:13
savedlema22-Jan-18 11:13 
AnswerRe: How to start a job listing,directory,ad site? Pin
A_Griffin25-Jan-18 0:39
A_Griffin25-Jan-18 0:39 
QuestionNote to self Pin
#realJSOP21-Jan-18 3:00
mve#realJSOP21-Jan-18 3:00 
PraiseRe: Note to self Pin
Richard Deeming22-Jan-18 8:24
mveRichard Deeming22-Jan-18 8:24 
Questioni want to fix this error Pin
Gani19-Jan-18 23:06
Gani19-Jan-18 23:06 
QuestionRe: i want to fix this error Pin
Richard MacCutchan20-Jan-18 0:24
mveRichard MacCutchan20-Jan-18 0:24 
AnswerRe: i want to fix this error Pin
Qobil30-Jan-18 4:52
Qobil30-Jan-18 4:52 
QuestionDiscovery Regarding CSS in MVC - Tip Pin
#realJSOP17-Jan-18 3:58
mve#realJSOP17-Jan-18 3:58 
AnswerRe: Discovery Regarding CSS in MVC - Tip Pin
Richard Deeming17-Jan-18 4:41
mveRichard Deeming17-Jan-18 4:41 
QuestionHow to send WhatsApp Message using node.js Pin
Chhabra_Ankur16-Jan-18 23:32
Chhabra_Ankur16-Jan-18 23:32 
QuestionDrag one element over another one in javascript Pin
seppi12356613-Jan-18 20:47
seppi12356613-Jan-18 20:47 
AnswerRe: Drag one element over another one in javascript Pin
Richard Deeming15-Jan-18 8:03
mveRichard Deeming15-Jan-18 8:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.