0

is it possible to put a form input in a button so that when i click it will pass the id to the next page . Current my button is generated by a database i need to put the DeviceId in to a hiddenfield in the button to pass to another page . Thanks

 while ( $row = mysql_fetch_object( $fetch ) ) {
            $sResults .= '<tr id="'. $row->DeviceID . '">';
            $sResults .= '<td>' . $row->DeviceID . '</td>';
            $sResults .= '<td>' . $row->Model . '</td>';
            $sResults .= '<td>' . $row->manufacturer . '</td>';
            $sResults .= '<td>' .'<INPUT TYPE=BUTTON value="Add to My List">'. '</td>';
3
  • 1
    Use a regular link eg <a href="yourpage.php?id=yourid">Add</a> You can style it like a button with css if needed Commented May 22, 2014 at 15:07
  • That works, with Bootstrap you don't need to create a CSS stylesheet. Commented May 22, 2014 at 15:09
  • Shove it into the action of the <form> tag Commented May 22, 2014 at 15:09

2 Answers 2

1

You can't make this, but you can make a hidden input.

<INPUT TYPE="HIDDEN" NAME="NAMEOFVALUE" VALUE="3">

Add this to your normal form and it will pass this information to ther server, and the visitor of the page can't see this.

Sign up to request clarification or add additional context in comments.

Comments

0

You could do it like this:

<form action="url/to/redirect?foo=bar">
  <input type="BUTTON" value="Add to My List"/>
</form>

You can either set the action value to pass the parameters you need or add hidden input fields:

<form action="url/to/redirect" method="POST">
  <input name"foo1" type="BUTTON" value="bar1"/>
  <input name"foo2" type="BUTTON" value="bar2"/>
  <input type="BUTTON" value="Add to My List"/>
</form>

While you're at it, you might want to escape the other values, so that you'll avoid XSS attacks [1]

1 - http://www.thegeekstuff.com/2012/02/xss-attack-examples/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.