Help!

Is it possible to post to different pages based on a value?


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Web Developers RSS
Next:  Sims 2 Holiday Edition wont install  
Author Message
mikal



Joined: Sep 11, 2007
Posts: 1



PostPosted: Tue Sep 11, 2007 10:20 am    Post subject: Is it possible to post to different pages based on a value?

Hello

I want to post to a form based on a value. Is this possible?

What I have is

<%
Dim Country
Country = Session("Country")
%>

I basically want to post to page1.com is Coutry = USA

<form name="myPage" action="https://page1.com"method=POST>

or if Country = UK post to

<form name="myPage" action="https://page1.co.uk"method=POST>

Can I do this and how would I go about it?

Many Thanks
Back to top
tyler785



Joined: Mar 08, 2008
Posts: 2



PostPosted: Sat Mar 08, 2008 12:53 am    Post subject:

I think you should be able to do this.

First set the country value in a hidden field somewhere on the page.

Code:
<input type="hidden" id="country" value="<?php echo Country;?>" />


In your submit button do an onclick to call some javascript. You can either do it inline or call a function and dynamically set the action of the form.

Code:

function setAction(){
var countryVal = document.getElementById('country').value;
if(countryVal == 'USA'){
     document.mypage.action ="https://page1.com";
} else if(countryVal == 'UK'){
     document.mypage.action ="https://page1.co.uk";
}
}


Calling that function in the onClick will make it execute before the forum action is called. I have never tried this but it should work with some good old javascript. Good luck!

Tyler
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Web Developers All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum