Results 1 to 8 of 8

Thread: forms

  1. #1


    guys here is my problem im making a quiz program and its a personality test and it uses javascript to work out their personality and here is my problem on question8.php
    <form method=post action=javascript:validate() name=question>
    <p>A Friend Is Over Do You:<input type=radio name=choice value=1>Panic<input type=radio name=choice value=2>relax<input type=submit value=choose></form>
    the javascript then does this:
    if(question.choice.value=1) {
    alert('Choice 1 accepted');
    alert('Choice 2 accepted');
    Here is my problem it doesnt know the value for some reason even after one have been checked

  2. #2
    You might want to try: if(question.choice.value==1). I think your problem is the one =.

  3. #3
    Join Date
    Feb 2003
    This will probably work for you:

    <script language="javascript">
    function validate()
    	if(question.choice[0].checked) {
    	alert('Choice 1 accepted');
    	alert('Choice 2 accepted');
    	return true;
    <form method="post" action="test.html" name="question" onsubmit="return validate();">
    A Friend Is Over Do You:
    <input type="radio" name="choice" value="1">Panic
    <input type="radio" name="choice" value="2">relax
    <input type="submit" value="choose">

  4. #4
    so choice[0] and choice[1]?

  5. #5
    Join Date
    Feb 2003
    choice[0] is the first radio button. choice[1] is the second.

  6. #6
    right ok is that the same for php?
    $choice[0] and $choice[1]?

  7. #7
    Join Date
    Jul 2003
    No, its not the same for PHP. It will be $_POST['choice'].
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  8. #8
    right so if i named the radio values to something like "val1" and "val2" would it be question.choice[val1]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts