Assigning a Value to a field in JavaScript

I want to update a field (DellPurchStatus) to approved - here is what I have today.  This code works, I just need to add

DellPurchStatus = Approved somewhere.

cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Accept Comment</title></head>'+
'<body><form><h3>Please Enter Any Comments Regarding Acceptence</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="opener.document.forms[0].DellPurchCom.value =document.forms[0].counterText.value;opener.document.forms[0].RefreshButton.onclick();self.close()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');

JaziarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

p_parthaCommented:
I am assuming dellpurchstatus to be in the parent window...

cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Accept Comment</title></head>'+
'<body><form><h3>Please Enter Any Comments Regarding Acceptence</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="opener.document.forms[0].DellPurchCom.value =document.forms[0].counterText.value;opener.document.forms[0].RefreshButton.onclick();opener.document.forms[0].DellPurchStatus="approved";self.close()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');
0
p_parthaCommented:
sorry a typo:
I am assuming dellpurchstatus to be in the parent window...

cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Accept Comment</title></head>'+
'<body><form><h3>Please Enter Any Comments Regarding Acceptence</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="opener.document.forms[0].DellPurchCom.value =document.forms[0].counterText.value;opener.document.forms[0].RefreshButton.onclick();opener.document.forms[0].DellPurchStatus.value="Approved";self.close()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JaziarAuthor Commented:
I am still getting error on page

opener.documents.forms.0.DellPurchStatus is null or not and object
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

p_parthaCommented:
Is DellPurchStatus field available in the main window or not, If yes then check the spelling

partha
0
JaziarAuthor Commented:
The DellPurchStatus is on the main form - the same form the action button is on.  It is a computed field with the default value of DellPurchStatus
0
JaziarAuthor Commented:
I am starting to think there is something wrong with the database.  Even though I completely remove any refrence to the field including deleting the field.  Saving and rebooting my PC.  When I run the new script without DellPurchStatus in it.  I get the same error the that field is null.  Strange Indeed
0
qwaleteeCommented:
The error is because as far as the browser is concerned, it is not a field.  Domino generates any editable fields as browser-recognized fields.  But any computed/computed for display fields are not generated -- being computed, they just display the text of the computation, which makes sense (think about it).

There is an option to override this behavior, called "generate HTML for all fields," on the second tab of form properties.  I do not like this opton, beause it can have unintended side effects.  There are other workarounds, but you might want to try this one first, even though I don't liek it particularly.
0
JaziarAuthor Commented:
After the change to Generate HMTL

I get the error "Approved" is undefined
0
Sjef BosmanGroupware ConsultantCommented:
sorry another typo:

cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Accept Comment</title></head>'+
'<body><form><h3>Please Enter Any Comments Regarding Acceptence</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="opener.document.forms[0].DellPurchCom.value =document.forms[0].counterText.value;opener.document.forms[0].RefreshButton.onclick();opener.document.forms[0].DellPurchStatus.value=\"Approved\";self.close()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');

You have to escape the quotes around the word Approved
0
JaziarAuthor Commented:
Now when I click the OK button it does nothing it just freezes.  I can then hit cancel and it removes the box.  I am getting no errors messages or anything.  Just sits there on screen

Taking points to 200

Not sure why this simple javascript is causing me so many headaches????
0
p_parthaCommented:
What are you doing on Refreshbutton ?.. try this then:

cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Accept Comment</title></head>'+
'<body><form><h3>Please Enter Any Comments Regarding Acceptence</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="opener.document.forms[0].DellPurchCom.value =document.forms[0].counterText.value;opener.document.forms[0].DellPurchStatus.value=\"Approved\";opener.document.forms[0].RefreshButton.onclick();self.close()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');
0
JaziarAuthor Commented:
WHen I go into the browser (web client)  I can not see any changes made to the javascript -

example

'<body><form><h3>Please Enter Any Comments Regarding Acceptence</h3>'+

I changed to
'<body><form><h3>Hello World</h3>'+

I saved, opened the browser and hit the action button and it still says

Please Enter Any Comments R........

It seems not to get the updated JavaScript

0
p_parthaCommented:
It's coming from the cache.. Do one thing clear your browser cache...

Partha
0
JaziarAuthor Commented:
Ok I will try to clear the cache and try again
0
JaziarAuthor Commented:
I cleared the Cache and that did not help.  I tried the same form in FireFox.  FireFox has a status bar on the bottom of the dialog box.  THe status goes about 3/4 quarters they and stops.  It really seems like the script is freezing somewhere
0
p_parthaCommented:
In firefox go to tools --> javascript console and paste what is the error that is reported..

Partha
0
JaziarAuthor Commented:
Error: syntax error
Source Code:
opener.document.forms[0].DellPurchCom.value =document.forms[0].counterText.value;opener.document.forms[0].RefreshButton.onclick();opener.document.forms[0].DellPchStatus.value=
0
p_parthaCommented:
it's getting complicated. Just do one thing, Your old code was working right, just add this line in the refreshbutton.click() before all teh lines:

document.forms[0].DellPurchStatus.value="approved"
0
JaziarAuthor Commented:
Good Morning!

I have set the code back to the start

cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Accept Comment</title></head>'+
'<body><form><h3>Please Enter Any Comments Regarding Acceptence</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="opener.document.forms[0].DellPurchCom.value =document.forms[0].counterText.value;opener.document.forms[0].RefreshButton.onclick();self.close()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');


This code works, I have tested it.  All is needed is the approval stamp in field DellPurchStatus.

When I add -> document.forms[0].DellPurchStatus.value="approved" (It stops working, I have also tried /"Approved/")

I was unable to test your latest suggestion Partha, due to I am not sure where to put the line
0
p_parthaCommented:
Can you paste what is in RefreshButton

Partha
0
JaziarAuthor Commented:
I resovled the problem by creating a text field on the form and setting it equal to approve.  Then just making the new field equal to that field with the static text.  I know it is not the correct way but it works.  I would like to say thanks to everyone that stayed with me on this on.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.