Link to home
Start Free TrialLog in
Avatar of Jaziar
Jaziar

asked on

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>');

Avatar of p_partha
p_partha

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>');
ASKER CERTIFIED SOLUTION
Avatar of p_partha
p_partha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jaziar

ASKER

I am still getting error on page

opener.documents.forms.0.DellPurchStatus is null or not and object
Is DellPurchStatus field available in the main window or not, If yes then check the spelling

partha
Avatar of Jaziar

ASKER

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
Avatar of Jaziar

ASKER

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jaziar

ASKER

After the change to Generate HMTL

I get the error "Approved" is undefined
SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jaziar

ASKER

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????
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>');
Avatar of Jaziar

ASKER

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

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

Partha
Avatar of Jaziar

ASKER

Ok I will try to clear the cache and try again
Avatar of Jaziar

ASKER

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
In firefox go to tools --> javascript console and paste what is the error that is reported..

Partha
Avatar of Jaziar

ASKER

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=
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"
Avatar of Jaziar

ASKER

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
Can you paste what is in RefreshButton

Partha
Avatar of Jaziar

ASKER

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.