views:

43

answers:

2
<a href="companies.php?id='. $_GET['id'] .'&offset='. $next_offset .'"><input id="button" type="button" value="More"/>

i somehow want to send &offset=avalue but useing a input button. without the id.

how can i do the similer thing with useing form action get ? like ( warning epic fail ) i should add a hidden input or something ?

    echo '<form action="welcome.php" method="get">';
    echo '<a href="companies.php?id='. $_GET['id'] .'&offset='. $next_offset .'"><input id="button" type="button" value="More"/></a>';      
    echo '</form>';

please comment if you guys dont understand thanks!

ok somehow i have manage to make it work

    echo '<form action="companies.php?id='. $_GET['id'].'" method="get">';
    echo '<input type="hidden" name="offset" value="'.$next_offset.'">';
    echo '<input id="button" type="submit" value="More"/></a>';     
    echo '</form>';

but still have an error http://localhost/networks/companies.php?offset=5, where does my get id goes ? btw im still checking it out and thanks guys :)

and aha! it works

    // MORE PLUGIN
    echo '<form action="companies.php" method="get">';
    echo '<input type="hidden" name="id" value="'.$_GET['id'].'">';
    echo '<input type="hidden" name="offset" value="'.$next_offset.'">';
    echo '<input id="button" type="submit" value="More"/></a>';     
    echo '</form>';
    // END PLUGIN

thanks guys

+2  A: 

For one thing, you can put parameter in the form's action attribute, just like you did with the link and href.

More readable option is hidden input element: <input type="hidden" name="offset" value="your_value">

Is this what you asked?

Nikita Rybak
ah the hidden thing. let me try :)
Adam Ramadhan
+2  A: 

<? echo '<input type=button onclick=\'window.location="companies.php?offset='. $next_offset .'"\'>';?>

Byron Whitlock
so why the downvote? this is a perfectly valid answer.
Byron Whitlock
Wow. Depending on JavaScript (bad practices are bad) **and** having invalid HTML that will probably have the onclick attribute cut off after the `location=` part of the value (thus being non-functional). It isn't even a complete PHP string.
David Dorward
@David I just missed a \' in there. added an echo for you. This question is so simple i didn't give it enough love. My bad. ;)
Byron Whitlock
It still isn't a complete PHP string (and the approach of nesting quotes three levels deep, and using concatenation instead of interpolation doesn't lead to the most readable code), and depending on JS for this is still a bad practice. Oh, and short tags are deprecated.
David Dorward
simple for you guys :) it works! but when there is no javascript ?
Adam Ramadhan
When there is no JavaScript, the user has a control that does nothing when activated.
David Dorward
@David - Also, have you tried browsing the web with JavaScript turned off? You would be surprised how much stuff just doesn't work at all.
Byron Whitlock
Since tripping over a JS bomb a couple of months back, I've been enjoying the NoScript extension for Firefox. It isn't *that* often that I come across a site that doesn't work. Most are better designed. (And no, before you ask, that isn't why I'm an advocate of progressive enhancement).
David Dorward
@David, thanks for pointing all these things out. I know them, but the OP probably doesn't. :D
Byron Whitlock