Avatar of zorba111
zorba111
 asked on

use javascript to request a page

We have a situation where were are in a form, but want a sub form to post (which I'm told will not work in HTML).

So... what if instead of using a subform, we provided a button which hooked into some javascript which requested the required page (in this case the same page).

Now I know javascript can request a page be launched in a new window, but how about in the same window/tab ?

i.e. the javascript replicates a HTML form/submit cycle ?
JavaScriptHTML

Avatar of undefined
Last Comment
zorba111

8/22/2022 - Mon
zorba111

ASKER
 window.location.replace("http://www.w3schools.com")

CAn this be used to supply parameters also, e.g.

  window.location.replace("http://www.w3schools.com?nameA=valueA&nameB=valueB")

?
zorba111

ASKER
window.open(URL,name,specs,replace)

Parameter       Description
URL       Optional. Specifies the URL of the page to open. If no URL is specified, a new window with about:blank is opened
name       Optional. Specifies the target attribute or the name of the window. The following values are supported:

    * _blank - URL is loaded into a new window. This is default
    * _parent - URL is loaded into the parent frame
    * _self - URL replaces the current page
    * _top - URL replaces any framesets that may be loaded
    * name - The name of the window

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

thanks w3schools....

_self looks promising - am I on the right track ?

cheers!!
ASKER CERTIFIED SOLUTION
Sinistra_D32

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Rok-Kralj

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
zorba111

ASKER
@Sinistra_D32:

thanks!

note to self (thnks wikipedia)

XMLHttpRequest (XHR) is a DOM API that can be used inside a web browser scripting language, such as JavaScript, to send an HTTP or an HTTPS  request directly to a web server and load the server response data directly back into the scripting language.[1]  Once the data is within the scripting language, it is available as both an XML document, if the response was valid XML markup,[2]  and as plain text.[3]  The XML data can be used to manipulate the currently active document in the browser window without the need of the client loading a new web page  document. Plain text data can be evaluated within the scripting language to manipulate the document, too; in the example of JavaScript, the plain text may be formatted as JSON by the web server and evaluated within JavaScript to create an object of data for use on the current DOM.

XMLHttpRequest has an important role in the AJAX web development technique. It is currently used by many websites to implement responsive and dynamic web applications. Examples of these web applications include Gmail, Google Maps, Bing Maps, the MapQuest dynamic map interface, Facebook, and others.

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes