Akasha Posted February 24, 2006 Share Posted February 24, 2006 Hello I have a form with 3 radiobuttons.Depending on which radio is selected , they will be redirected to a pagebut it doesn't matter which button i click all 3 are going to the same page (add_project) what am i doing wrong? here is the code of my form <p class="gen"><b>What would you like to ...</b></p> <form name='form' method='post'> <input type="radio" name="choice" value="Add" onclick="goto()"/> add a project? <input type="radio" name="choice" value="Edit" onclick="goto()"/> edit a project you have added? <input type="radio" name="choice" value="Delete" onclick="goto()"/> delete a project you have added?</form> here is the code of my javascriptfunction function goto(){ for (i=0;i<document.forms[0].elements.length;i++) { if (document.forms[0].elements[i].checked) { if (document.forms[0].elements[i].value = "Add") location.href = "add_project.asp" else if (document.forms[0].elements[i].value = "Edit") location.href = "edit_project.asp" else if (document.forms[0].elements[i].value = "Delete") location.href = "delete_project.asp" } } } Link to comment Share on other sites More sharing options...
scott100 Posted February 24, 2006 Share Posted February 24, 2006 There is no need for a function to do what you want, just put an onclick on the radio button then a new window.location. <p class="gen"><b>What would you like to ...</b></p> <form name='form' method='post'> <input type="radio" name="choice" value="Add" onclick="window.location='add_project.asp'"/> add a project? <input type="radio" name="choice" value="Edit" onclick="window.location='edit_project.asp'"/> edit a project you have added? <input type="radio" name="choice" value="Delete" onclick="window.location='delete_project.asp'"/> delete a project you have added?</form> If i have misunderstood then let me know. Link to comment Share on other sites More sharing options...
Akasha Posted February 24, 2006 Author Share Posted February 24, 2006 Thnx alot that's so much easier :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now