Hi to all,
am having problem doing this.
i want to show a link and not a button.when the link is clicked,then the <form></form> content is echoed for the user to make a choice,this should not open a new window,all this should take place on the same page.another problem i have is that it do not work in firefox and opera,it only work once or twicw in windows explower.
if anyone can help,i will be grateful.or if anyone have another code that can do the samething,you are welcome.

<?php
function action()
{
echo "<form action='' method='post'>
<select id='select3' name='select3' class='bodytxt'>
                              
<option selected='selected' class='bodytxt'>&nbsp;&nbsp;&nbsp;-- Customise --</option>
                              <option>Anyone</option>
                              <option>Only Females</option>
                              <option>Only Males</option>
                              <option>Alumni</option>
                              <!--when the user select Alumni 4fm the list,a list of all the alumni will show up, and the user will pick one,from which pics willappear-->
                            </select>
							</form>";
}
echo "<input type='button' name='Release' onclick= action(); value='Click Here' class='bodyTxt'>";
?>

PHP is server-side code. It gets executed in its entirety on the server before the user's browser sees anything. Therefore, you cannot call a PHP function the way you're doing it, with in onClick event. What you want to do is make action() a JavaScript function instead. You can create an empty div on the page, like <div id="contentGoesHere"></div> and then have your JavaScript action() function change the content of that div.

Another [more complicated] option would be to use an AJAX request when the user clicks the button and pull in the HTML code from a separate PHP file.

PHP is server-side code. It gets executed in its entirety on the server before the user's browser sees anything. Therefore, you cannot call a PHP function the way you're doing it, with in onClick event. What you want to do is make action() a JavaScript function instead. You can create an empty div on the page, like <div id="contentGoesHere"></div> and then have your JavaScript action() function change the content of that div.

Another [more complicated] option would be to use an AJAX request when the user clicks the button and pull in the HTML code from a separate PHP file.

My problem with the avascript is that i just found out i can not user more than one link onthe same page.

do you have any examples of AJAX ?
pls. let me know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.