Hi
I am trying to find the answer of the following. Suppose, I am trying to build a web page to conduct a fictious online Poll and people vote their favourite candidate. Now each voter is allowed to vote only one candidate from any one party. I have made the code with JavaScript and HTML. But the problem is that, after voting the Candidate and pressing Submit, the page should open another new page where the voter must select any one name of the party to which the candidate belongs and Submit again. But my problem is that, I am trying to open that new page in the place of the existing page but its only opening in a new window. Putting '_self' doesn't work! (I am using radio buttons. It also needs form vaildation so the voter must vote!) What went wrong?
<HTML>
<TITLE>Votes</TITLE>
<HEAD>
<script LANGUAGE="JavaScript">
function form_validation(form)
{
ErrorText= "";
if ((form.name[0].checked==false) && (form.name[1].checked==false) && (form.name[2].checked==false) && (form.name[3].checked==false) && (form.name[4].checked==false) && (form.name[5].checked==false) && (form.name[6].checked==false))
{
alert ("Please select from the form");
return false;
}
if ((form.name[0].checked==true) || (form.name[1].checked==true) || (form.name[2].checked==true) || (form.name[3].checked==true) || (form.name[4].checked==true) || (form.name[5].checked==true) || (form.name[6].checked==true))
{
return true;
}
}
function window_open() {
window.open("party_names.html","_self");
}
</script>
<BODY>
<H3 style="color:green"><CENTER>Welcome to Voting Page</CENTER></H3>
<p>This is the website for Voting your favourite candidate<br/>
and the respective Party</p>
<p style="color:blue">Please fill in the form below to select the desired Candidate name and Submit:</p>
<FORM name="Candidate_name" >
<B>Candidates:</B>:<br>
First set:<br>
<INPUT TYPE="radio" name="name" value="name" /><i>Bob</i><br/>
<INPUT TYPE="radio" name="name" value="name" /><i>Mary</i><br/>
<INPUT TYPE="radio" name="name" value="name" /><i>John</i><br/>
Second set:<br>
<INPUT TYPE="radio" name="name" value="name" /><i>Joe</i><br/>
<INPUT TYPE="radio" name="name" value="name" /><i>Gilbert</i><br/>
<INPUT TYPE="radio" name="name" value="name" /><i>Frank</i><br/>
<INPUT TYPE="radio" name="name" value="name" /><i>Sudhir</i><br/></br>
<input type="Submit" value="Submit" onClick="return form_validation(this.form) && window_open();">
<input type="reset" value="Reset">
</FORM>
</BODY>
</HTML>
Please use any html file of yours as party_names.html. If you omit "_self" from it, then it'll work properly. But that opens a new window for party_names.html. But I want it to open the new page in the same window carrying the data selected from both pages in order to process in the server.
Please help and EXPLAIN my mistake as I am new.
Thanks