Sunday, November 14, 2010

How do i make a HTML form redirect to different pages based on responses to a form?

I have a HTML form with two drop down boxes with the options 'Yes' and 'No' in each. When submitted, i want the form to direct the user to one page if both responses are yes, and another page if either response is no. Can anyone give me some very simple guidelines on how to do this, or where i could find a nice tutorial about it?How do i make a HTML form redirect to different pages based on responses to a form?
check out these HTML tutorial videos .. with they r helpful :)

http://www.mytopclip.com/search.phpHow do i make a HTML form redirect to different pages based on responses to a form?
Use Javascript.



%26lt;html%26gt;

%26lt;script type=';text/javascript';%26gt;

function switchit()

{

聽聽聽var frm = document.forms[0];

聽聽聽if (frm)

聽聽聽{

聽聽聽聽聽聽if ((frm.myfield1.value = ';no';) || (frm.myfield3.value = ';no';))

聽聽聽聽聽聽聽聽聽return 0;

聽聽聽聽聽聽else

聽聽聽聽聽聽{

聽聽聽聽聽聽聽聽聽// change the action for the form to a different web page and submit it

聽聽聽聽聽聽聽聽聽frm.action=';someotherpage.php?br>
聽聽聽聽聽聽聽聽聽frm.submit();

聽聽聽聽聽聽}

聽聽聽}

}

%26lt;/script%26gt;



%26lt;body%26gt;

%26lt;form action=';switchit();'; type=';post';%26gt;

%26lt;select name=';myfield1';%26gt;

%26lt;option value=';yes';%26gt;Yes%26lt;/option%26gt;

%26lt;option value=';no';%26gt;No%26lt;/option%26gt;

%26lt;/select%26gt;

%26lt;input type=';text'; name=';myfield2';%26gt;

%26lt;select name=';myfield3';%26gt;

%26lt;option value=';yes';%26gt;Yes%26lt;/option%26gt;

%26lt;option value=';no';%26gt;No%26lt;/option%26gt;

%26lt;/select%26gt;

%26lt;/form%26gt;



%26lt;/body%26gt;

%26lt;/html%26gt;
You can use Javascript window or php header(location:

No comments:

Post a Comment