JavaScript ? -- set field, save, openurl

These questions should be easy for a JavaScript guru, but not for me the “newbie”:

  1. how do I set a field in Javascript?

  2. how do I save a form in Javascript? (need to do this in JS, and not from a submit button)

  3. how do I go to a new URL in JS, within the same window?

Thank you in advance…I’m sure there are places in the forum I could find these answers, but I’m under a bit of a time crunch! :slight_smile:

Subject: JavaScript ? – set field, save, openurl

You might want to go to just about ANY web page on the internet and VIEW the SOURCE. You can pick up your js from there.

dzp

Subject: JavaScript ? – set field, save, openurl

  1. how do I set a field in Javascript?document.forms[0].fieldname.value = value

fieldname is case sensitive

  1. how do I save a form in Javascript? (need to do this in JS, and not from a submit button)

document.forms[0].submit()

  1. how do I go to a new URL in JS, within the same window?

var path=location.pathname

var loc=path.indexOf(“.nsf”)

var filename=path.substring(0,loc)+“.nsf”

location.href = filename + “/MyView?OpenView”

Subject: RE: JavaScript ? – set field, save, openurl

Thanks, this is awesome and just what I was looking for!

Subject: JavaScript ? – set field, save, openurl

Go buy Danny Goodman’s JavaScript Bible or visit one of the many, many Javascript sites on the net!

Subject: RE: JavaScript ? – set field, save, openurl

While I appreciate the point towards a book, I’m in a big time crunch…can someone help?

Subject: RE: JavaScript ? – set field, save, openurl

Look on the web! There are way too many free sites dedicated to this topic. That is what you are paid for, not asking people to give you the code!

http://www.google.com/search?num=100&hl=en&c2coff=1&safe=active&q=Javascript+resources&spell=1

Subject: RE: JavaScript ? – set field, save, openurl

Hmmm, I guess I should have remembered that before giving code to the many people I’ve helped out on this site. It was an emergency, I didn’t have time…give me a break.

Subject: JavaScript ? – set field, save, openurl

These questions should not be answered in 10 seconds, if this app is really as urgent as you state, than you may want to hire a partner/developer with the skills needed. However here are some 10 second answers…

  1. how do I set a field in Javascript?

uidoc=document.forms[0];

uidoc.fieldname.value= the value you want

  1. how do I save a form in Javascript?

document.forms[0].submit() ;

Subject: JavaScript ? – set field, save, openurl

Here is a helpful trick you might like:

Create a button on your form and load it up with formula language to make it do whatever you want. Like:

FIELD Saved := “yes”;

@Command([FileSave]);

@Command([ToolsRunMacro] ; “WebDoSomethingAgent”)

or whatever. In the HTTP tab, give the button a name like saveButton. In the Style field for the button, put in visibility:hidden. You now have an invisible button that will save the document.

Now, whenever you want to use that button, use:

document.forms(0).saveButton.click()

Hope that helps.

-Mike

Subject: RE: JavaScript ? – set field, save, openurl

Thanks! That’s a great tip and I will definitely do that – Formula Language is definitely easier when it comes to what I need, I just need it work on the web. And thanks for not giving me attitude either :slight_smile:

Subject: I answered and gave some attitude, so I covered both sides!