|
I'm having a lot of trouble with this assignment for my class. I'm in desperate need of help because this is due Friday at midnight. Any help would be greatly appreciated!
PART 1
FUNCTION NAME
product
LANGUAGE
JavaScript
PARAMETERS
1 PARAMETERS
FUNCTION HEADER
function product (parameter1) {
OBJECTIVE OF FUNCTION
Multiply two values and return the result.
HTML OBJECT
There is a form named "myForm" with a textbox named "myTextbox". They exist. Just use them.
PARAMETER
The is a parameter with a numeric value.
WHAT TO DO
Return the parameter times myTextbox's value.
This is what I have so far,
function product(parameter1) {
value1 = myForm.myNumber; // this is value 1 right here.
value2 = document.getElementById('myTextbox').value;
total = parameter1 * value2; // The total is the text box value.
return total; // I just returned the total of the function.
};
|
|
|
|
|
Nice one...But shouldn't you use parameter1 and not that myNumber?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
תפסיק לספר לה' כמה הצרות שלך גדולות, תספר לצרות שלך כמה ה' גדול!
|
|
|
|
|
What is your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
my controller code:-
public class HomeController : Controller
{
erpEntities db = new erpEntities();
public ActionResult Index()
{
string mysql = "select * from modules where parentid=3";
IEnumerable<Module> results = db.ExecuteStoreQuery<Module>(mysql);
string itemString = "<table width='100px'><tr>";
string itemString1 = "";
Int32 ParentID = 0;
Int32 ParentValue = 0;
Int32 LevelID = 0;
Int32 Mcounter = 0;
Int32 LastValue = 0;
foreach (var itemMain in results)
{
LevelID += 1;
itemString1 += "<input type='hidden' id='LastValue" + LevelID + "' value=0>\n";
itemString += "<td valign='top'><table width='200px'>";
itemString += "<tr><td><b>" + itemMain.Title + "<b><td></tr>";
mysql = "select Id,title from t" + itemMain.ID;
IEnumerable<ChildData> results1 = db.ExecuteStoreQuery<ChildData>(mysql);
Mcounter = 0;
foreach (var item in results1)
{
Mcounter += 1;
string tt1 = item.ID.ToString();
string tt2 = item.ID.ToString();
string HidVar = Mcounter + "$" + LevelID;
itemString += "<tr><td>";
itemString += "<input type='hidden' id='Child$" + HidVar + "' Value='" + item.ID + "'>";
itemString += "<input type='checkbox' id='chk$" + HidVar + "' value='' onclick='javascript:clickme(\"" + HidVar + "\"," + tt1 + "," + tt2 + "," + Mcounter + "," + LevelID + ");'><a href='#' onclick='javascript:clickme(\"" + HidVar + "\"," + tt1 + "," + tt2 + "," + Mcounter + "," + LevelID + ");'>" + item.Title + "</a>";
//itemString += "<input type='checkbox' id='chk$" + ParentID + "$" + itemMain.ID + "$" + item.ID + "$" + LevelID + "' value=''><a href='#' onclick='javascript:clickme(\"" + HidVar + "\"," + tt1 + "," + tt2 + "," + LevelID + ");'>" + item.Title + "</a>";
itemString += "</td></tr>";
}
ParentID = itemMain.ID;
itemString += "</td></table>";
}
itemString += "</tr></table>";
//var ttp = db.t787.ToList();
//itemString += "<table>";
//foreach (var item in ttp)
//{
// string tt1 = item.ID.ToString();
// string tt2 = item.ID.ToString();
// itemString += "<tr><td>";
// itemString += "<input type='hidden' id='modChild$786' value=1>";
// itemString += "<input type='checkbox' id='child$1$t7862" + item.ID + "'><a href='#' onclick='javascript:clickme(" + tt1 + "," + tt2 + ");'>" + item.Title + "</a>";
// itemString += "</td></tr>";
//}
//itemString += "</table>";
ViewData["mystring"] = (itemString + itemString1);
return View();
}
My index.cshtml code:=
@{
ViewBag.Title = "Home Page";
// Response.Write(""" + "Hello"+""");
}
<script language="javascript" type="text/javascript">
var results = new Array();
function clickme(HidVar, txt, txt1,Mcounter, LevelID, ignore,rb)
{
//var input = document.createElement("input");
//input.setAttribute("type", "hidden");
//input.setAttribute("name", "name_you_want");
//input.setAttribute("value", "value_you_want");
var ChildValue = document.getElementById("Child$" + HidVar).value;
var chk = document.getElementById("chk$" + HidVar).checked;
//alert(chk);
// var chk1 = document.getElementById("chk$" + HidVar).checked = true;
if (LevelID > 1) {
for (index = 1; index < 4; ++index) {
if (Mcounter != index && document.getElementById("chk$" + HidVar).checked) {
document.getElementById("chk$" + index + "$" + LevelID).disabled = true;
}
if (document.getElementById("chk$" + HidVar).checked == false) {
document.getElementById("chk$" + index + "$" + LevelID).disabled = false;
}
}
}
document.getElementById("LastValue" + LevelID).value = ChildValue;
var ParentValue = 0;
if (LevelID > 1) {
ParentValue = document.getElementById("LastValue" + (LevelID - 1)).value;
}
else {
ParentValue = document.getElementById("LastValue" + (LevelID)).value;
}
// function checkbox(me, group) {
//load History
//alert("Level ID: " + LevelID);
//Remove Status - Unchecked all the value for a child Level
var OneToOne = 1;
for (index = 0; index < results.length; ++index) {
if (results[index][2] >= (LevelID + 1)) {
document.getElementById("chk$" + results[index][4] + "$" + results[index][2]).checked = false;
//document.getElementById("chk$" + results[index][4] + "$" + results[index][2]).disabled = true;
}
}
//One to One Checking
var OneToNE = 0;
var ChildStatus = 0;
//Setting Status - checked all the value for a child Level
for (index = 0; index < results.length; ++index) {
if (results[index][0] == ChildValue && results[index][2] >= (LevelID + 1)) {
document.getElementById("chk$" + results[index][4] + "$" + results[index][2]).checked = true;
if (OneToNE == 0) {
//document.getElementById("chk$" + results[index][4] + "$" + results[index][2]).disabled = false;
}
ChildStatus = 1
}
}
//Checking if exist
var exist = 0;
for (index = 0; index < results.length; ++index) {
if (results[index][0] == ParentValue && results[index][1] == ChildValue && results[index][2] == LevelID && results[index][4] == Mcounter) {
exist = 1;
if (chk == false && ChildStatus == 0) {
removeByIndex(results, index);
}
else {
document.getElementById("chk$" + results[index][4] + "$" + results[index][2]).checked = true;
}
}
}
//IF not exist then storing in the array
if (exist == 0) {
results.push([ParentValue, ChildValue, LevelID, HidVar, Mcounter, " "]);
}
document.getElementById("demo").innerHTML = results;
}
function removeByIndex(arr, index) {
arr.splice(index, 1);
}
</script>
<form name="addForm">
<input id="Button1" type="button" value="value" />
@Html.Raw(ViewData["mystring"]);
</form>
|
|
|
|
|
That's way too much code for me to go through, would it be possible to just narrow down your code to a few lines, and rephrase your question, like which array in which code?
|
|
|
|
|
Hello,
When an item is selected it's automatically stretches the textbox with an extra line instead of stay on the same height, when the size is fixed specified, see example: http://jsfiddle.net/g332c2ru/9/
is this a issue? because when an item is selected and it's to long we don't want a new line is created. I tried with css to create an solution but nothing worked.
greetings,
Sander
|
|
|
|
|
Hi
I have same image in my page with same class $(.'cross') several times. When I click to get the ID of the clicked one, it does not work for the first time but it works one the second click.
I am using Gridster and my html is built dynamically on DOM Load like this with local variables.
gridster.add_widget.apply(gridster, ['<li id="li' + Grid.GridID + '" itemid="' + Grid.GridID + '" class="gs-w" data-row="' + Grid.GriddataRow + '" data-col="' + Grid.GriddataCol + '">Report id :' + Grid.GridItemid + '<table data-role="table" id="table' + Grid.GridID + '" class="icon"><tr><td><img id="cross' + Grid.GridID + '" class="cross" height="10" width="10" src="../images/Icones/cross.gif" alt="cross' + Grid.GridID + '" onclick="CloseGrid();" /></td><td><;img id="icon' + Grid.GridID + '" class="menu" height="10" width="10" src="../images/tbordmenuicon.png" alt="icon' + Grid.GridID + '" onclick="showMenu(event);GetClickedIcon();" /></td></tr></table><div id="container' + Grid.GridID + '" style="width:100%;height:100%;margin: 0 auto"></div></li>', Grid.GriddataX, Grid.GriddataY]);
And my closeGrid () function looks like this:
function CloseGrid() {
$('.cross').click(function() {
var id = $(this).attr('id').replace('cross', '');
alert(id);
if (confirm("Voulez-vous définitivement supprimer ce graphique?")) {
gridster.remove_widget($('#li' + id), false);
DeleteChart(id);
}
else {
return false;
}
});
}
Could you please check and tell me what I am doing wrong?
I checked same forums about it but I could not find the problem.
Thanks in advance.
|
|
|
|
|
Guys,
It always happens to me that I start something with the zeal but soon I found lack of motivation continuing it.
Imagining myself a javascript expert turned me on and I decided to get certification in JS. Read few chapters and as usual just put it aside.
So trying new way of achieving the goal I am in the search of a study pal.
I wonder if anyone of you would be interested getting javascript certificate and would like to become a study pal to keep the motivation up till the end.
Some code of conduct: No personal information exchange except your name. No other conversation apart from the topic.
|
|
|
|
|
I am in a situation to use http://www.trirand.net/demo/aspnet/mvc/jqgrid/[^] in my project. So i just want to know whether it has MIT license or not? Is there anyone who already uses it in his/her project. Please help me through this.
So much complexity in software comes from trying to make one thing do two things.
Sibeesh
|
|
|
|
|
Is Google[^] not available in your company?
The first result for "jqgrid license" is:
The jqGrid is dual licensed and is released under GPL or MIT licenses.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you . i will check it out.
So much complexity in software comes from trying to make one thing do two things.
Sibeesh
|
|
|
|
|
|
Thank you . i will check it out.
So much complexity in software comes from trying to make one thing do two things.
Sibeesh
|
|
|
|
|
hi,
I have a requirement in the jqgrid data that totally 3 columns in that one is name,date and one column called department where the edit type is select have two options education and humanresources.
for some records like up to this month 10/31 the records should be editable , i mean we can select some thing and we can update. only the current month should be editable and next month data should not editable we can view it but not edit just like should be in read mode.
How to approach this scenario?
$("#grid").jqGrid({
url: 'Handler.ashx',
datatype: 'json',
height: 250,
colNames: ['Name','Department', 'Date'],
colModel: [
{ name: 'Name', index: 'Name', width: 256, stype: 'text', editable: true, sortable: false, editoptions: { disabled: "disabled"} },
{ name: 'Department', index: 'Department', width: 256, stype: 'text', sortable: false, editable: true, edittype: 'select',
formatter: rowColorFormatter,
editoptions: { value: "Education:Education; Humanresource:Humanresource" }},
{ name: 'Date', index: 'Date', width: 256, editable: true, stype: 'text', sortable: true, sorttype: 'date', editoptions: { disabled: "disabled"} }
],
rowNum: 100,
loadonce: true,
rowList: [100, 200, 300],
pager: '#pager',
sortname: 'name',
viewrecords: true,
sortorder: 'asc',
gridview: true,
ignoreCase: true,
caseSensitive: false,
rownumbers: true,
reloadAfterSubmit: false,
width: 1024,
gridComplete: function() {
for (var i = 0; i < rowsToColor.length; i++) {
var Department = $("#" + rowsToColor[i]).find("td").eq(2).html();
if (Department == "Humanresource") {
$("#" + rowsToColor[i]).find("td").css("background-color", "red");
}
}
},
jsonReader: {
repeatitems: false
},
caption: 'Department Update',
editurl: 'Handler.ashx',
onSelectRow: function(id) {
if (id && id !== lastSelectedId) {
$('#grid').restoreRow(lastSelectedId);
$('#grid').editRow(id, true);
lastSelectedId = id;
}
},
afterSubmit: function() {
$(this).jqGrid("setGridParam", { datatype: 'json' });
return [true];
alert("returnvalue");
}
});
function rowColorFormatter(cellValue, options, rowObject) {
if (cellValue == "Humanresources")
rowsToColor[rowsToColor.length] = options.rowId;
return cellValue;
};
$("#grid").setGridParam({ sortname: 'CalDate', sortorder: 'asc' }).trigger('reloadGrid');
$("#grid").jqGrid('navGrid', '#pager',
{
edit: false,
add: false,
del: false,
search: true,
searchtext: "Search",
reloadAfterSubmit: true,
cloneToTop: true,
overlay: false,
beforeRefresh: function() {
$("#grid").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid');
}
}
});
$("#grid").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: "cn" }).navButtonAdd('#pager', {
caption: "Export to Excel",
buttonicon: "ui-icon-disk",
onClickButton: function() {
ExportDataToExcel("#grid");
},
position: "last"
});
$("#grid").jqGrid('editRow', {
aftersavefunc: function() {
onEnterrowdetails('#list');
}
});
});
function ExportDataToExcel(tableCtrl) {
ExportJQGridDataToExcel(tableCtrl, "MKS.xlsx");
}
function onEnterrowdetails() {
$('#<%=lblMessage.ClientID%>').html(" Data Updated");
return true;
}
</script>
</form>
</body>
</html>
|
|
|
|
|
We have a .Net webservice which runs on one server and a web application (javascript) running on another. The webservice needs to have Windows Authentication.
We keep getting the error 401 Unauthorized on the CORS Preflight call, which preceeds the cross domain webservice call. If we move the webservice on the same machine as the application, the calls run perfectly.
Spent four days now to get it working, hopefully someone here can point me in the right direction...
P.S.: added a JSFiddle which demonstrates the problem. http://jsfiddle.net/mr9Lpbc1/34/[^]
Here is the web.config we use for the webservice
="1.0"="UTF-8"
<configuration>
<appSettings />
<connectionStrings />
<system.web>
<compilation debug="true" />
<authentication mode="Windows" />
<customErrors mode="Off" />
<webServices>
<protocols>
<add name="HttpSoap" />
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
<httpRuntime maxUrlLength="9999" relaxedUrlToFileSystemMapping="true" maxQueryStringLength="2097151" requestValidationMode="2.0"/>
<pages validateRequest="false" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<remove value="default.aspx" />
<remove value="Default.asp" />
<remove value="index.html" />
<remove value="iisstart.htm" />
<remove value="index.htm" />
<remove value="Default.htm" />
<add value="webservice.asmx" />
</files>
</defaultDocument>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="http://domain.nl" />
<add name="Access-Control-Allow-Credentials" value="true" />
<add name="Access-Control-Allow-Headers" value="SOAPAction, Content-Type,Authorization" />
<add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS" />
</customHeaders>
</httpProtocol>
<security>
<requestFiltering>
<requestLimits maxUrl="10999" maxQueryString="9999" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
Here is the peace of javascript we are using
SOAPClientParameters = (function () {
function SOAPClientParameters() {
var self = this;
self.list = new Array();
}
SOAPClientParameters.prototype.add = function (name, value) {
var self = this;
self.list[name] = value;
return self;
};
SOAPClientParameters.prototype._serialize = function (o) {
var s = "";
switch (typeof (o)) {
case "string":
s += o;
case "number":
case "boolean":
s += o.toString(); break;
case "object":
if (testNull(o)) { s += ""; }
else if (typeof o === 'Date') {
dateToSqlString(o);
}
else if (typeof o === 'Array') {
for (var p in o) {
if (!isNaN(p))
{
(/function\s+(\w*)\s*\(/ig).exec(o[p].constructor.toString());
var type = RegExp.$1;
switch (type) {
case "":
type = typeof (o[p]);
case "String":
type = "string"; break;
case "Number":
type = "int"; break;
case "Boolean":
type = "bool"; break;
case "Date":
type = "DateTime"; break;
}
s += "<" + type + ">" + SOAPClientParameters._serialize(o[p]) + "</" + type + ">"
}
else
s += "<" + p + ">" + SOAPClientParameters._serialize(o[p]) + "</" + p + ">"
}
}
else
for (var p in o)
s += "<" + p + ">" + SOAPClientParameters._serialize(o[p]) + "</" + p + ">";
break;
default:
throw new Error(500, "SOAPClientParameters: type '" + typeof (o) + "' is not supported");
}
return s;
}
SOAPClientParameters.prototype.toXml = function () {
var self = this;
var xml = "";
for (var p in self.list) {
if (typeof self.list[p] !== 'function') {
xml += "<" + p + ">" + self._serialize(self.list[p]) + "</" + p + ">";
}
}
return xml;
}
return SOAPClientParameters;
}());
SOAPClient = (function () {
function SOAPClient(url, async) {
var self = this;
self.xmlHttp = null;
if (window.XMLHttpRequest) {
self.xmlHttp = new XMLHttpRequest();
if (self.xmlHttp.readyState == null) {
self.xmlHttp.readyState = 1;
self.xmlHttp.addEventListener("load",
function () {
self.xmlHttp.readyState = 4;
if (typeof self.xmlHttp.onreadystatechange == "function")
self.xmlHttp.onreadystatechange();
},
false);
}
} else {
throw 'This browser is not supported!';
}
self.xmlHttp.async = async;
if (self.xmlHttp !== null) {
self.xmlHttp.open("POST", url, self.xmlHttp.async);
self.xmlHttp.url = url;
self.xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
self.xmlHttp.onerror = function () {
if (self.xmlHttp.async) {
var errorClient = new SOAPClient(self.xmlHttp.url, false);
var exception = errorClient.invoke(self.xmlHttp.func, self.xmlHttp.parameters, function () { }, function () { });
self.xmlHttp.errorCallback(isnull(exception.message, 'Unknown error...'));
}
}
self.xmlHttp.onload = function () {
if ((self.xmlHttp.readyState === 4) && (self.xmlHttp.status !== 200)) {
self.xmlHttp.errorCallback(self.xmlHttp.statusText);
}
}
}
}
SOAPClient.prototype.result = function (data) {
return data;
};
SOAPClient.prototype.invoke = function (method, parameters, successCallback, errorCallback) {
var self = this;
var ns = 'http://domain.com/';
var sr = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<" + method + " xmlns=\"" + ns + "\">" +
parameters.toXml() +
"</" + method + "></soap:Body></soap:Envelope>";
var soapaction = ((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + method;
self.xmlHttp.function = method;
self.xmlHttp.parameters = parameters;
self.xmlHttp.errorCallback = errorCallback;
self.xmlHttp.setRequestHeader("SOAPAction", soapaction);
if (self.xmlHttp.async) {
self.xmlHttp.onreadystatechange = function () {
if ((self.xmlHttp.readyState == 4) && (self.xmlHttp.status === 200)) {
self.onSuccess();
}
}
}
try {
self.xmlHttp.send(sr);
if (!self.xmlHttp.async) {
self.onSuccess();
}
} catch (ex) {
return ex;
}
}
SOAPClient.prototype.onSuccess = function () {
var self = this;
if ((self.xmlHttp.readyState == 4) && (self.xmlHttp.status === 200)) {
var o = null;
var responseText = self.xmlHttp.response;
}
}
return SOAPClient;
}());
modified 9-Oct-14 8:03am.
|
|
|
|
|
|
|
struggling to figure out this program. beginner javascript programmer.
My task is to write a program that does this: Stores the 50 states' names and capitals in two arrays (which I have).
Uses the window.prompt() method to display a state name, asks the user to enter the matching capital name, and tells the user that entering "exit" will stop the program.
Checks the user input and use the window.prompt() method to tell the user if the answer is correct or not. At the same time, the window.prompt() method displays the next state name, and asks the user to enter the next matching capital name. Please note that giving the user feedback and prompting the user to try the next are done with the same window.prompt().
Uses a loop to go through all 50 states until all 50 states have been displayed or the user enters "exit".
Any guidance would be much appreciated. Even just getting pointed in the right direction. I've read through many tutorials and just can't seem to get it. Thank you.
|
|
|
|
|
Post only once please!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
struggling to figure out this program. beginner javascript programmer.
My task is to write a program that does this: Stores the 50 states' names and capitals in two arrays (which I have).
Uses the window.prompt() method to display a state name, asks the user to enter the matching capital name, and tells the user that entering "exit" will stop the program.
Checks the user input and use the window.prompt() method to tell the user if the answer is correct or not. At the same time, the window.prompt() method displays the next state name, and asks the user to enter the next matching capital name. Please note that giving the user feedback and prompting the user to try the next are done with the same window.prompt().
Uses a loop to go through all 50 states until all 50 states have been displayed or the user enters "exit".
Any guidance would be much appreciated. Even just getting pointed in the right direction. I've read through many tutorials and just can't seem to get it. Thank you.
|
|
|
|
|
Member 11116351 wrote: My task So start do it! Do not wait for us to do it for you! Thing are work a bit differently. YOU came with some (probably imperfect) solution and WE help you make it work...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
|
Please do not post same question multiple times
|
|
|
|
|
I tried the ckEditor forum but I was listed as a spammer and denied a post, until they resolve it.
Any body here know much about ckEditor Custom Plugins, and the element ID system?
[SOLVED]
Well the ckEditor forum was no help either. But I figured it out the next day.
modified 26-Sep-14 17:53pm.
|
|
|
|
|
Hi,
I am gonna start a new web application which gives more importance to client side rather than server side. So we have so many technologies to achieve the client side scripting. eg :- JQuery,JavaScript,Angular JS. Among these which one should i use for my project?
Thanks In Advance
Sibeesh
|
|
|
|
|