Web Hosting Talk







View Full Version : Removing an option from php code?


Johnburk
02-25-2006, 07:18 AM
In the following code, please have to select a radio button and then press OK.

How can this be made so that when pressing OK it is automaticly selected as the value of beeing checked?


echo "<div class='content'>";echo "<form action=\"subscription.php\" method=\"post\" name=\"sub_form\"".($popup ? " target=\"formPopup\"" : "")." onsubmit=\"submitform();false;\"> <input type=\"text\" size=\"".($popup ? "15" : "15")."\" name=\"email_addr\" value=\"".translate("EMAIL_ADDRESS")."\" onfocus=\"if (this.value=='".translate("EMAIL_ADDRESS")."') this.value=''\" />&nbsp;<input type=\"button\" name=\"sub\" value=\" OK \" onclick=\"submitform()\" /><br />\n <input type=\"radio\" class='radio' name=\"op\" value=\"join" ; if(!$conf->sub_validation) echo "_direct"; echo "\" checked=\"checked\" /> ".translate("NEWSLETTER_SUBSCRIPTION")."\n"; echo "\t\t<input type=\"radio\" class='radio' name=\"op\" value=\"leave"; if(!$conf->unsub_validation) echo "_direct"; echo "\" /> ".translate("NEWSLETTER_UNSUBSCRIPTION");


Thank you.

hehachris
02-25-2006, 08:54 AM
not too sure wt did u mean...

from my understanding
u meant when submitting the form, email_addr field will be automatically selected so that the user do not need to click on it?

Johnburk
02-25-2006, 10:02 AM
not too sure wt did u mean...

from my understanding
u meant when submitting the form, email_addr field will be automatically selected so that the user do not need to click on it?

This code is from a newsletter script

Right now people have to fill in their email, then select to suscribe or un-suscribe and the press ok.

How can de suscribe and un-suscribe button be deleted, so that people automaticly are suscribed when pressing OK.

UptimeAgent
02-25-2006, 10:09 AM
Hi.

1. Suggestion: you can use the following style:
<?
//PHP code
?>

HTML code

<?
PHP code
?> instead of
<?

//PHP code

echo "HTML CODE";
echo "Another HTML line";
echo "HTML CODE...";

//PHP code

?>
If you are aware of the mentioned approach but deliberately choose the second method then please disregard this suggestion.

2. As hehachris stated, it would be good if you specify your question because it's unclear what exactly you would like to have as a result.

UptimeAgent
02-25-2006, 10:18 AM
This code is from a newsletter script

Right now people have to fill in their email, then select to suscribe or un-suscribe and the press ok.

How can de suscribe and un-suscribe button be deleted, so that people automaticly are suscribed when pressing OK.
Please try this:
echo "<div class='content'>";echo "<form action=\"subscription.php\" method=\"post\" name=\"sub_form\"".($popup ? " target=\"formPopup\"" : "")." onsubmit=\"submitform();false;\"> <input type=\"text\" size=\"".($popup ? "15" : "15")."\" name=\"email_addr\" value=\"".translate("EMAIL_ADDRESS")."\" onfocus=\"if (this.value=='".translate("EMAIL_ADDRESS")."') this.value=''\" />&nbsp;<input type=\"button\" name=\"sub\" value=\" OK \" onclick=\"submitform()\" /><br />\n <input type=\"hidden\" name=\"op\" value=\"join\" /> ";

hehachris
02-25-2006, 10:57 AM
yea according to UptimeAgent
simply remove the radios
and add a hidden value unless u modify the php code (submitted part)

Johnburk
02-25-2006, 11:32 AM
Please try this:
echo "<div class='content'>";echo "<form action=\"subscription.php\" method=\"post\" name=\"sub_form\"".($popup ? " target=\"formPopup\"" : "")." onsubmit=\"submitform();false;\"> <input type=\"text\" size=\"".($popup ? "15" : "15")."\" name=\"email_addr\" value=\"".translate("EMAIL_ADDRESS")."\" onfocus=\"if (this.value=='".translate("EMAIL_ADDRESS")."') this.value=''\" />&nbsp;<input type=\"button\" name=\"sub\" value=\" OK \" onclick=\"submitform()\" /><br />\n <input type=\"hidden\" name=\"op\" value=\"join\" /> ";

Thanks. I tried it by get a error