Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

Call Two Different Weblinks for one Java File

I have the need to call two separate weblinks from one java script file.  Is this possible?
The first link will initiate the login screen.  The second link will pass a variable that will retrieve a specific page (document).

I want to embed this in one file and then be able to pass the variable to the java script file when I run it.  If java script is not the way to go but it is doable, please let me know that also.
0
Elroy Taulton
Asked:
Elroy Taulton
  • 3
1 Solution
 
for_yanCommented:
Sure, there is no reason why you cannot have two functions in your javascript - and one would go
to one screemn, another - to another screen
For example below I show how you can have two buttoins which call differnt javscript functions
and inside each yone you can direct to different lnks, say using
location= ...link here...
statment of JavaScript



<input type="button" onClick="goToLogin()" value="Go To Login"></tr>

<input type="button" onClick="goToAnotherPage()" value="Go to another page"></tr>

Open in new window


You can do it just with simple links also


This question is  related to JavaScript but should not beling to Java Programming Language
0
 
Elroy TaultonDevelopment ManagerAuthor Commented:
So for instance, how would I list the following two links?

http://server.com/idm/hms/ca12/index.jsp?task.tag=HMSSearchHWSWRequests 

http://server.com/idm/hms/ca12/hms/page/jsp/ViewAllUserEquipmentRequestHistoryController.jsp?searchFilterValue=PurchaseOrderNumber&poValue=<PONUM>

PONUM is a variable that I will be passing to the script.  But I want the second link to be performed automatically, without additional user input; if that makes sense.

0
 
for_yanCommented:

Waht you may do - you can have a form and
put  the second link as its action.

Then when yuser just presses enter it will go there.
For the first link you cna make a button within your html page as  I wrote above

and then you shoule add a small javscript function in the head of your page that
woul put your first link as location

I''ll post a simple examnple of such function
0
 
for_yanCommented:


Before the body of your page
put this function:
<script>
function goToAnotherPage(){

location="http://server.com/idm/hms/ca12/index.jsp?task.tag=HMSSearchHWSWRequests" ;
}
</script>

Open in new window


and in the body :

<input type="button" onClick="goToAnotherPage()" value="Go to another page"></tr>

Open in new window


and another URL should go to the action of your form
and then there will be Submit button of the form
and it will go to that action URL also when yuser just presses enter

and to the sceond one only if the user presses this button Go to another page
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now