Text link from button with hidden form fields

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cdickson
Forum Contributor
Posts: 120
Joined: Mon Apr 05, 2004 1:30 pm
Location: Michigan, USA

Text link from button with hidden form fields

Post by cdickson »

Is there any way I can create a text link from a button with a myriad of hidden form fields?
Code for form field is:

Code: Select all

<form action="test.php" method="POST">
	  <input type="submit" value="Get Comments">
	  <input type="hidden" name="user" value="SAMPLE">
	  <input type="hidden" name="pass" value="test123">
	  <input type="hidden" name="sessid" value="1">
	  <input type="hidden" name="tablename" value="sample">
	  <input type="hidden" value="07" name="startdate-month">
	  <input type="hidden" value="01" name="startdate-date">
	  <input type="hidden" value="2005" name="startdate-year">
	  <input type="hidden" value="12" name="enddate-month">
	  <input type="hidden" value="31" name="enddate-date">
	  <input type="hidden" value="2005" name="enddate-year">
	  <input type="hidden" value="All Patients" name="categoryid">
	  <input type="hidden" value="12" name="demographic">
	  <input type="hidden" name="survey_question" value="53">
	  <input type="hidden" name="patcomments" value="">
	  <input type="hidden" name="answer" value="A.Better than expected">
	  <input type="hidden" name="report" value="Get Comments Only"></td>
</form>
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Not quiet sure what you mean but how about using method="GET"?
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Also, you could use session to keep part of the information like username, password, session validity etc.
cdickson
Forum Contributor
Posts: 120
Joined: Mon Apr 05, 2004 1:30 pm
Location: Michigan, USA

Post by cdickson »

I need to rephrase my question and update my code from a sample page that was given to me previously to the actual code that is in place.

Following is the code being used to generate the report and the "Get Comments" submit button. The goal is to generate the same report using a text link instead of the submit button. I appreciate the previous input, but I'm a little green and still need some coaching.

Code: Select all

echo '<form action="test.php" method="POST">';
            echo '<td align="center" class="report_data_count">';
            echo '<input type="submit" value="Get Comments">';
            echo '<input type="hidden" name="user" value="'.$_POST['user'].'">';
            echo '<input type="hidden" name="pass" value="'.$_POST['pass'].'">';
            echo '<input type="hidden" name="sessid" value="'.$_POST['sessid'].'">';
            echo '<input type="hidden" name="tablename" value="'.$GLOBALS['TEST']['TABLE_NAME'].'">';
            echo '<input type="hidden" value="'.$_POST['startdate-month'].'" name="startdate-month">';
            echo '<input type="hidden" value="'.$_POST['startdate-date'].'" name="startdate-date">';
            echo '<input type="hidden" value="'.$_POST['startdate-year'].'" name="startdate-year">';
            echo '<input type="hidden" value="'.$_POST['enddate-month'].'" name="enddate-month">';
            echo '<input type="hidden" value="'.$_POST['enddate-date'].'" name="enddate-date">';
            echo '<input type="hidden" value="'.$_POST['enddate-year'].'" name="enddate-year">';
            echo '<input type="hidden" value="'.$_POST['categoryid'].'" name="categoryid">';
            echo '<input type="hidden" value="'.$REPORT_DATA['DEMOGRAPHIC_ID'].'" name="demographic">';
            echo '<input type="hidden" name="survey_question" value="'.$REPORT_DATA['SURVEY_QUESTION_ID'].'">';
            echo '<input type="hidden" name="patcomments" value="">';
            echo '<input type="hidden" name="answer" value="'.  $REPORT_DATA['SURVEY_QUESTION_LIST'][$x] .'">';
            echo '<input type="hidden" name="report" value="Get Comments Only">';
            echo '</td>';
            echo '</form>';
Thanks to anyone willing to help.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Ok, how about adding a link with an onClick event set to the form submission?

You could clean your form removing the table information (<td>) and the submit button and then give it a name:

Code: Select all

echo '<form name="comment_form" action="test.php" method="POST">';
echo '<input type="hidden" name="user" value="'.$_POST['user'].'">';
echo '<input type="hidden" name="pass" value="'.$_POST['pass'].'">';
echo '<input type="hidden" name="sessid" value="'.$_POST['sessid'].'">';
echo '<input type="hidden" name="tablename" value="'.$GLOBALS['TEST']['TABLE_NAME'].'">';
echo '<input type="hidden" value="'.$_POST['startdate-month'].'" name="startdate-month">';
echo '<input type="hidden" value="'.$_POST['startdate-date'].'" name="startdate-date">';
echo '<input type="hidden" value="'.$_POST['startdate-year'].'" name="startdate-year">';
echo '<input type="hidden" value="'.$_POST['enddate-month'].'" name="enddate-month">';
echo '<input type="hidden" value="'.$_POST['enddate-date'].'" name="enddate-date">';
echo '<input type="hidden" value="'.$_POST['enddate-year'].'" name="enddate-year">';
echo '<input type="hidden" value="'.$_POST['categoryid'].'" name="categoryid">';
echo '<input type="hidden" value="'.$REPORT_DATA['DEMOGRAPHIC_ID'].'" name="demographic">';
echo '<input type="hidden" name="survey_question" value="'.$REPORT_DATA['SURVEY_QUESTION_ID'].'">';
echo '<input type="hidden" name="patcomments" value="">';
echo '<input type="hidden" name="answer" value="'.  $REPORT_DATA['SURVEY_QUESTION_LIST'][$x] .'">';
echo '<input type="hidden" name="report" value="Get Comments Only">';
echo '</form>';
Then place the link with the proper event in the exact point where you want it:

Code: Select all

echo '<a href="#" onClick="javascript:document.comment_form.submit();">Get Comments</a>';
Hope that helps :)
rssajkow
Forum Newbie
Posts: 11
Joined: Mon Oct 02, 2006 1:03 am

submit link

Post by rssajkow »

you can also make a standard submit button and then make it look like a text link with css, this will allow use of the post method. IE....<input type="submit" name="submit" value="submit" class="details">

input.details
{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px; line-height:13px;
font-weight: normal;
color:#0000FF;
padding:0;
margin:0;


background-color:transparent;
text-decoration: none;
border: none;
cursor: pointer;
cursor: hand;
}
input.details:hover
{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px; line-height:18px;
font-weight: normal;
color:#FF0000;

background-color:transparent;
text-decoration: underline;
border: none;
cursor: pointer;
cursor: hand;
}
cdickson
Forum Contributor
Posts: 120
Joined: Mon Apr 05, 2004 1:30 pm
Location: Michigan, USA

Post by cdickson »

Excellent ideas! Thanks - I will try them both and see which works best.
Post Reply