# Trouble with retrieving field value and update value

**URL:** <https://forums.knack.com/t/trouble-with-retrieving-field-value-and-update-value/7246>\
**Category:** API & Custom Code\
**Created:** [November 10, 2017, 11:28pm UTC](https://forums.knack.com/t/trouble-with-retrieving-field-value-and-update-value/7246 "2017-11-10T23:28:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanPinder68638](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DanPinder68638](https://forums.knack.com/u/DanPinder68638)\
**Post date:** [November 10, 2017, 11:28pm UTC](https://forums.knack.com/t/trouble-with-retrieving-field-value-and-update-value/7246/1 "2017-11-10T23:28:32Z")

</div>

I wrote some code that works to push to another site... but something really basic I am having trouble with..

I just want to do if field.value != value, then button text is X, else its XY.

But the basic problem is I can't even get the field value to show up in an alert. I get 'undefined'. What am I missing? Something simple.

$(document).on('knack-scene-render.scene\_3', function(event, scene, view) {  
//check to see if quote already submitted  
// if (condition) {  
// block of code to be executed if the condition is true  
//}  
 alert($('#view\_4.field\_38'.val()));  
$('#view\_4 .view-header').after('\<div style="padding:15px"\>\<a href="#" id="webmerge" class="kn-button"\>Send Quote\</a\>\</div\>');

So the second thing I want to do is after the form is submitted update a date field with the current date, and update the previous field to be a different value also. What is the correct was to do this? This

//change status to submitted  
// field\_38:"Bid Submitted";  
 //get current date  
var today = new Date();  
var dd = today.getDate();  
var mm = today.getMonth()+1; //January is 0!  
var yyyy = today.getFullYear();

if(dd\<10) {  
 dd = '0'+dd  
}

if(mm\<10) {  
 mm = '0'+mm  
}

today = mm + '/' + dd + '/' + yyyy;  
   
// field\_44:today;

---

<div class="post-metadata">

**Author:** ![CarlMasri03739](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@CarlMasri03739](https://forums.knack.com/u/CarlMasri03739)\
**Post date:** [December 4, 2017, 4:40pm UTC](https://forums.knack.com/t/trouble-with-retrieving-field-value-and-update-value/7246/2 "2017-12-04T16:40:21Z")

</div>

```
alert($('#view_4.field_38'.val()));
```

should be

```
alert($('#view_4.field_38').val());
```
