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('','','heig ht=150,wid th=300,sta tus');
cw.moveTo(200,200);
cw.document.write('<html>< head><titl e>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].D ellPurchCo m.value =document.forms[0].counter Text.value ;opener.do cument.for ms[0].Refr eshButton. onclick(); self.close ()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()"> '+
'</form></body></html>');
DellPurchStatus = Approved somewhere.
cw=window.open('','','heig
cw.moveTo(200,200);
cw.document.write('<html><
'<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.
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">
'</form></body></html>');
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am still getting error on page
opener.documents.forms.0.D ellPurchSt atus is null or not and object
opener.documents.forms.0.D
Is DellPurchStatus field available in the main window or not, If yes then check the spelling
partha
partha
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
After the change to Generate HMTL
I get the error "Approved" is undefined
I get the error "Approved" is undefined
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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????
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('','','heig ht=150,wid th=300,sta tus');
cw.moveTo(200,200);
cw.document.write('<html>< head><titl e>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].D ellPurchCo m.value =document.forms[0].counter Text.value ;opener.do cument.for ms[0].Dell PurchStatu s.value=\" Approved\" ;opener.do cument.for ms[0].Refr eshButton. onclick(); self.close ()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()"> '+
'</form></body></html>');
cw=window.open('','','heig
cw.moveTo(200,200);
cw.document.write('<html><
'<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.
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">
'</form></body></html>');
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
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
Partha
ASKER
Ok I will try to clear the cache and try again
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
Partha
ASKER
Error: syntax error
Source Code:
opener.document.forms[0].D ellPurchCo m.value =document.forms[0].counter Text.value ;opener.do cument.for ms[0].Refr eshButton. onclick(); opener.doc ument.form s[0].DellP chStatus.v alue=
Source Code:
opener.document.forms[0].D
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].DellPurc hStatus.va lue="appro ved"
document.forms[0].DellPurc
ASKER
Good Morning!
I have set the code back to the start
cw=window.open('','','heig ht=150,wid th=300,sta tus');
cw.moveTo(200,200);
cw.document.write('<html>< head><titl e>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].D ellPurchCo m.value =document.forms[0].counter Text.value ;opener.do cument.for ms[0].Refr eshButton. 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].DellPurc hStatus.va lue="appro ved" (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
I have set the code back to the start
cw=window.open('','','heig
cw.moveTo(200,200);
cw.document.write('<html><
'<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.
">"+
'<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].DellPurc
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
Partha
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.
cw=window.open('','','heig
cw.moveTo(200,200);
cw.document.write('<html><
'<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.
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">
'</form></body></html>');