Making a Poll in PHP
I have been trying to figure out how the radiobutton works...
You see my poll has 3 options
Vote1
Vote2
Vote3
Now IF Vote1 is checked (radiobutton) then
print "it works";
but how does my code know if the radiobutton is checked or not?
I tryied this code but it wont work:
<?php
if (form1.radio.checked){
echo "it works";
?>
Please help!!
doublehelix posted this at 15:10 — 1st May 2002.
They have: 117 posts
Joined: Feb 2002
The radio button passes a different value depanding on which is selected. For example
You know which radio button is selected by the value passed, ie:
if (form1.radio.value == "selction_one")
.
.
.
etc.
deep posted this at 16:04 — 1st May 2002.
They have: 14 posts
Joined: Apr 2002
ok i tryied this:
Vote1
Vote2
Vote3
<?php
if (form1.r.value == "v1"){
print "works";
}
?>
But it still wont write "works" on the screen
Why?
doublehelix posted this at 18:28 — 1st May 2002.
They have: 117 posts
Joined: Feb 2002
Well, I'm not a php expert, but I don't think your problem has to do with the conditional statement. i think your problem is trying to print to the page after it has been loaded. To put it in simpler javascript terms, when you create, or load a page, you go through this sequence...
document.open();
document.write();
document.close();
In HTML the closing body tag is issuing a body.close(). Once that command had been issued you can no longer write to a page. I think your conditional is working just fine, but the document has already been closed. I think your form would have an action to call a page that had your conditional check on it that then created another page.
Mark Hensler posted this at 19:56 — 1st May 2002.
He has: 4,048 posts
Joined: Aug 2000
Vote1
Vote2
Vote3
<?php
if ($r == "v1"){
print "works";
}
?>
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.