Jump to content
xisto Community
adly3000

Javascript And Php

Recommended Posts

Are you using Radio buttons for your polls? If yes then when you submit the forum then it will submit that information, however if you want to use JS to edit the page ou can do a hidden forum field with the answer then submit it.

Share this post


Link to post
Share on other sites

It depends on weather you are using a form or not. If you are using a form, in your javascript, you will submit the form. In this case make sure your radiobutton group or checkbox (whatever you use for selecting the choice) is part of the form. If you are not using form, you will have to redirect to the php script in your url with selected choice value as parameter.

In your php script, you can obtain the value from $_REQUEST variable array.

For example, if you have radio_1 as one radio button group, you can get the selected value by

$sel1=$_REQUEST['radio_1'];

Share this post


Link to post
Share on other sites

thanks all;

kvkv i understand your words.u mean i should pass the selectd checkbox to the url then identify it by $_request in php!!

is that what do you mean?

225975[/snapback]


Yes. But the easier way is to use a form.

 

Ex:

 

<FORM ACTION="evaluate.php"><INPUT TYPE=CHECKBOX NAME="sel_1">Answer_1<INPUT TYPE=CHECKBOX NAME="sel_2">Answer_2<INPUT TYPE=CHECKBOX NAME="sel_3">Answer_3<INPUT TYPE=CHECKBOX NAME="sel_4">Answer_4<INPUT TYPE=SUBMIT></FORM>

This will give you multiple check boxes (4 in this case) with a submit button. When user selects the answer and clicks submit button, it will be submitted to the action script (evaluate.php in above example). You don't have to pass any values in url explicitly, but if the checkbox is selected, the variable will be automatically available in the action script.

Share this post


Link to post
Share on other sites

sorry my demands needs javascript in code, here is a part of my code:

$pollAnswers .= "<form name=\"poll" . $pollid . "\" method=\"post\">\n";	$pollAnswers .= "<table width=\"100%\" dir=\"rtl\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"" . $pollbgcolor . "\">\n";	$num_results2 = mysql_num_rows($result2);	if ($num_results2 > 0)	{  while ($row2 = mysql_fetch_array($result2))  {  	$pollAnswers .= "<tr>\n";  	$pollAnswers .= "<td width=\"5\" align=\"center\"><input type=\"radio\" name=\"sel\" value=\"" . $row2["id"] . "\" onClick=\"document.poll" . $pollid . ".hsel.value='" . $row2["id"] . "';\"></td>\n";  	$pollAnswers .= "<td width=\"100%\" align=\"right\" nowrap><font face=\"" . $pollfontface . "\" size=\"" . $pollfontsize . "\" color=\"" . $pollfontcolor . "\" style=\"MARGIN-RIGHT: 5px; MARGIN-LEFT: 0px\">" . $row2["Choice"] . "</font></td>\n";  	$pollAnswers .= "</tr>\n";  }  $pollAnswers .= "<tr>\n";  $pollAnswers .= "<td height=\"5\" colspan=\"2\" nowrap><spacer type=\"vertical\" height=\"5\"></td>\n";  $pollAnswers .= "</tr>\n";  $pollAnswers .= "<tr>\n";  $pollAnswers .= "<td colspan=\"2\">\n";  $pollAnswers .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"" . $polltfooterbgcolor . "\">\n";  $pollAnswers .= "<tr>\n";  $pollAnswers .= "<td width=\"50%\" align=\"center\"><input type=\"button\" name=\"submit\" value=\"submit\" onClick=\"openVote('$pollid',document.poll" . $pollid . ".hsel.value)\"></td>\n";  $pollAnswers .= "<td width=\"50%\" align=\"center\"><a href=\"javascript: openResult('$pollid')\"><font face=\"" . $polltfooterfontface . "\" size=\"" . $polltfooterfontsize . "\" color=\"" . $polltfooterfontcolor . "\">view results</font></a></td>\n";  $pollAnswers .= "</tr>\n";  $pollAnswers .= "</table>\n";  $pollAnswers .= "</td>\n";  $pollAnswers .= "</tr>\n";	}	$pollAnswers .= "</table>\n";	$pollAnswers .= "<input type=\"hidden\" name=\"hsel\" value=\"\">\n";	$pollAnswers .= "</form>\n";

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.