473,327 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

The entered dijit value doesn't display the Json string, need solution thanks million

Expand|Select|Wrap|Line Numbers
  1. MY HTML CODE:
  2. <script>
  3. require(["dojo/parser", "dojo/json",
  4.                          "dijit/form/FilteringSelect",
  5.                          "dijit/form/TextBox",
  6.                          "dijit/form/Textarea",
  7.                          "dijit/form/Button",
  8.                          "dijit/form/ValidationTextBox",
  9.                          "dijit/form/DateTextBox"]);
  10.         </script>    
  11.     </head>
  12.             <body class="claro" bgcolor="pink" onload='disablet()'>
  13.                 <h1>PRODUCT MASTER</h1>
  14.                 <div class="grouping" id="divid">
  15.  
  16.                 <label for="pcode">PRODUCT CODE:</label>
  17.                 <input type="text" name="pname" id="product code" value="" required="required"
  18.                 data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="regExp:'[^\d{1,10}$]+', invalidMessage:'Invalid enter only number between 1-10.'" />
  19.                 <br>
  20.  
  21.                 <label for="pname">PRODUCT NAME:</label>
  22.                 <input type="text" name="pname" id="product name" value="" required="required"
  23.                 data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="regExp:'[a-zA-z]+', invalidMessage:'Invalid enter only Text.'" />
  24.                 <br>
  25.  
  26.                 <label for="ptype">PRODUCT TYPE:</label>
  27.                 <select data-dojo-type="dijit/form/FilteringSelect" id="product type" name="ptype">
  28.                     <option value="rm">RAW MATERIALS</option>
  29.                     <option value="ip">INTERMEDIATE OPTION</option>
  30.                     <option value="fp">FINISHED PRODUCT</option>
  31.                 </select>
  32.                    <br>
  33.  
  34.                 <label for="unit">UNIT MEASUREMENT:</label>
  35.                 <select data-dojo-type="dijit/form/FilteringSelect" id="unit measurement" name="unit">
  36.                     <option value="kg">KG</option>
  37.                         <option value="G">G</option>
  38.                         <option value="t">TONE</option>
  39.                         <option value="m">Meter</option>
  40.                 </select>
  41.                 <br>
  42.  
  43.                 <label for="create">CREATED DATE:</label>
  44.                  <input type="text" name="CDATE" id="created date" value="1992-08-20" required="required"
  45.                 data-dojo-type="dijit/form/DateTextBox"/>
  46.                 <br>
  47.                 </div>
  48.                     <button id="UPDATE" value="UPDATE" onclick="UpdateJSON()">UPDATE</button>
  49.                     <h1>JSON</h1>
  50.         <span id="spnJSON"></span>
  51.     </body>
  52. </html>
MY JAVASCRIPT CODE:
Expand|Select|Wrap|Line Numbers
  1. function UpdateJSON() {
  2.  
  3.  
  4.     var json = {PRODUCTCODE : 2, PRODUCTNAME : 'dd', PRODUCTTYPE : 'fg', UNITMEASUREMENT : 'g', CREATEDDATE : '2007-12-05'};
  5.  
  6.  
  7.             var purchase = eval('(' + json + ')');
  8.             purchase.PRODUCTCODE=dijit.byId("product code").value;
  9.             purchase.PRODUCTNAME=dijit.byId("product name").value;
  10.             purchase.PRODUCTTYPE=dijit.byId("product type").value;
  11.             purchase.UNITMEASUREMENT=dijit.byId("unit measurement").value;
  12.             purchase.CREATEDDATE=dijit.byId("created date").value;
  13.  
  14.             json = JSON.stringify(purchase);
  15.             dojo.byId("spnJSON").innerHTML = json; 
  16.         }
  17.  
  18.  
Feb 20 '14 #1

✓ answered by Dormilich

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
Dormilich
8,658 Expert Mod 8TB
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).
Feb 20 '14 #2
Thanks Dormilich, I'm new to JSON and DOJO, Could you please so kind and modify my coding? Thanks in advance... :)
Feb 20 '14 #3
Dormilich
8,658 Expert Mod 8TB
replace line #7 by var purchase = {};
Feb 21 '14 #4
ya,dormilich i got it thankyou.
Expand|Select|Wrap|Line Numbers
  1. var jsonstr= {"productcode":dijit.byId("productcode").attr("value"),...}
Feb 21 '14 #5
Dormilich
8,658 Expert Mod 8TB
technically, it’s still a JavaScript object.
Feb 21 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
9
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...
1
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)...
1
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:...
3
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...
2
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..........
7
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();...
6
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...
5
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...
0
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'} };...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
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...
0
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...
1
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)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.