- MY HTML CODE:
-
<script>
-
require(["dojo/parser", "dojo/json",
-
"dijit/form/FilteringSelect",
-
"dijit/form/TextBox",
-
"dijit/form/Textarea",
-
"dijit/form/Button",
-
"dijit/form/ValidationTextBox",
-
"dijit/form/DateTextBox"]);
-
</script>
-
</head>
-
<body class="claro" bgcolor="pink" onload='disablet()'>
-
<h1>PRODUCT MASTER</h1>
-
<div class="grouping" id="divid">
-
-
<label for="pcode">PRODUCT CODE:</label>
-
<input type="text" name="pname" id="product code" value="" required="required"
-
data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="regExp:'[^\d{1,10}$]+', invalidMessage:'Invalid enter only number between 1-10.'" />
-
<br>
-
-
<label for="pname">PRODUCT NAME:</label>
-
<input type="text" name="pname" id="product name" value="" required="required"
-
data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="regExp:'[a-zA-z]+', invalidMessage:'Invalid enter only Text.'" />
-
<br>
-
-
<label for="ptype">PRODUCT TYPE:</label>
-
<select data-dojo-type="dijit/form/FilteringSelect" id="product type" name="ptype">
-
<option value="rm">RAW MATERIALS</option>
-
<option value="ip">INTERMEDIATE OPTION</option>
-
<option value="fp">FINISHED PRODUCT</option>
-
</select>
-
<br>
-
-
<label for="unit">UNIT MEASUREMENT:</label>
-
<select data-dojo-type="dijit/form/FilteringSelect" id="unit measurement" name="unit">
-
<option value="kg">KG</option>
-
<option value="G">G</option>
-
<option value="t">TONE</option>
-
<option value="m">Meter</option>
-
</select>
-
<br>
-
-
<label for="create">CREATED DATE:</label>
-
<input type="text" name="CDATE" id="created date" value="1992-08-20" required="required"
-
data-dojo-type="dijit/form/DateTextBox"/>
-
<br>
-
</div>
-
<button id="UPDATE" value="UPDATE" onclick="UpdateJSON()">UPDATE</button>
-
<h1>JSON</h1>
-
<span id="spnJSON"></span>
-
</body>
-
</html>
MY JAVASCRIPT CODE: - function UpdateJSON() {
-
-
-
var json = {PRODUCTCODE : 2, PRODUCTNAME : 'dd', PRODUCTTYPE : 'fg', UNITMEASUREMENT : 'g', CREATEDDATE : '2007-12-05'};
-
-
-
var purchase = eval('(' + json + ')');
-
purchase.PRODUCTCODE=dijit.byId("product code").value;
-
purchase.PRODUCTNAME=dijit.byId("product name").value;
-
purchase.PRODUCTTYPE=dijit.byId("product type").value;
-
purchase.UNITMEASUREMENT=dijit.byId("unit measurement").value;
-
purchase.CREATEDDATE=dijit.byId("created date").value;
-
-
json = JSON.stringify(purchase);
-
dojo.byId("spnJSON").innerHTML = json;
-
}
-
-
problem #1, the "JSON" (line #4) is not a JSON string but already a JavaScript object (and it wouldn’t be valid JSON as well).
problem #2, line #8 - #12 make the original object obsolete (overwriting all values)
issue #3, if JavaScript encounters an error, you will find it listed in the error console (F12).
5 1675
problem #1, the "JSON" (line #4) is not a JSON string but already a JavaScript object (and it wouldn’t be valid JSON as well).
problem #2, line #8 - #12 make the original object obsolete (overwriting all values)
issue #3, if JavaScript encounters an error, you will find it listed in the error console (F12).
Thanks Dormilich, I'm new to JSON and DOJO, Could you please so kind and modify my coding? Thanks in advance... :)
replace line #7 by var purchase = {};
ya,dormilich i got it thankyou. - var jsonstr= {"productcode":dijit.byId("productcode").attr("value"),...}
technically, it’s still a JavaScript object.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dave |
last post by:
Hi
I m facing strange problem...
I have one field char type data length 1..
It has data either 1 or 2 in all the field tht I have
checked through enterprise manager.
I'm running query
"select...
|
by: Protoman |
last post by:
Why doesn't this display the string?
string decrypt(const string& ciphertext,const string& key)
{
string decrypted;
decrypted.resize(ciphertext.size()); // allocates the string for the
correct...
|
by: fusillo |
last post by:
i've a problem with the following statement:
var eg=eval('('+strjson+')');
making debug with firebug, a firefox extension i got
>>> typeof(strjson)
"string"
>>> inspect(strjson)...
|
by: quantass |
last post by:
Im using C#, ASP.NET v1.1. My class contains intrinsic types,
ArrayList, and XmlDocument types. Some variables have the value NULL.
After usng XmlSerializer and the information on:...
|
by: asleepatdesk |
last post by:
Hi,
I need some help here. When I try to eval() my AJAX returned JSON
string, I continually get a javascript error "Expected )".
Here's my JSON string:
{"recs": };
My js function simply...
|
by: bylabylamo |
last post by:
i have a problem converting a json string that i get from a servlet into a json object using eval function of java script. any one please help me..........
|
by: Andrew Poulos |
last post by:
I'm creating a JSON string and passing it to a SCORM 1.2 compliant LMS thus:
var tmp = {};
tmp.assess = assessScore;
tmp.loc = location;
tmp.progress = notes.topics.toString();...
|
by: pbd22 |
last post by:
Hi.
I can't seem to get any values from the below string.
I have tried myJSONObject.slides, myJSONObject.slides,
myJSONObject.slides.1, etc.
I can't get it to work. Is it because the NAMES are...
|
by: najmi |
last post by:
hai..
i hava use FullCalendar in my application.i try to reload event into the calendar but it doesn`t work.here is my code
<%@ page import="java.util.HashMap;" %>
<%@ page...
|
by: liadmz |
last post by:
Hi,
I would like to parse JSON string using perl.
which is very trivial up until the moment the elements name are unknown.
normally I would use:
my @elem= @{ $decoded->{'elements'} };...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| | |