I am creating a button in php and want to call a php with parameter when clicked:
echo '<form method="get" action="./ash.php?q=Y" >';
echo '<button type="submit" >QUERY</button>';
echo '</form>';
When I click on the button, ash.php gets indeed called, but the q parameter has been 'forgotten' in the process.
How can that be?
echo '<form method="get" action="./ash.php" >';
echo '<input type="hidden" name="q" value="Y" />';
echo '<button type="submit" >QUERY</button>';
echo '</form>';
Related
//Search button for SeekingAlpha
echo '<div id="searchAlpha">';
echo '<FORM NAME="form1" ACTION="http://www.seekingalpha.com/symbol/" METHOD="POST">';
echo '<INPUT TYPE="TEXT" NAME="symbol" placeholder="Search by symbol, author, keyboard..." / VALUE="<?php echo $symbol;?> "> <INPUT TYPE="SUBMIT" VALUE="Submit">';echo '</FORM>'; echo '</div>'; //end SeekingAlpha
My question is - How do I exactly get the textfield variable to the URL?
For instance - when a user type a stock symbol into the textfield, it would type out as http://www.seekingalpha.com/symbol/$symbol where $symbol is the input from textfield
Thanks!
I want to disable a button after the button onclick and then enable the other one .
echo '<input type="text" id="txtbox1" name="tb1" value="'.$value.'" />';
echo '<input type="submit" id="btn1" name = "btnstart" value="START" onClick="this.disabled=true;"/><input type="submit" id="btn2" name = "btnend" value="End" onClick="this.disabled=true;"/>';
In this case, i can only disable the button but the rest of the process skipped. I cannot update the input textbox value.
Also, How can i disable the btn2 the before onclick btn1?
$value= $_POST['tb1'];
echo '<form name="f1" method="POST" action="">';
echo '<input type="text" id="txtbox1" name="tb1" value="'.$value.'" />';
echo '<input type="submit" id="btn1" name = "btnstart" value="START" onClick="this.disabled=true;"/><input type="submit" id="btn2" name = "btnend" value="End" onClick="this.disabled=true;"/>';
echo '</form>';
echo '</td>';
if ( isset( $_POST['tb1'] ) ) {
$new = $value *12;
}
Try this:
<input type="submit" id="btn1" name = "btnstart" value="START" onClick="document.getElementById('btn2').disabled=false;this.disabled=true;"/>
<input type="submit" id="btn2" name = "btnend" value="End" onClick="this.disabled=true;" disabled/>
Working example: jsfiddle
Can you try this,
How can i disable the btn2 at the before onclick btn1?
Added onClick="document.getElementById(\'btn2\').disabled=true;this.disabled=true;"
echo '<input type="text" id="txtbox1" name="tb1" value="'.$value.'" />';
echo '<input type="submit" id="btn1" name = "btnstart" value="START" onClick="document.getElementById(\'btn2\').disabled=true;this.disabled=true;"/>
<input type="submit" id="btn2" name = "btnend" value="End" onClick="this.disabled=true;"/>';
try jquery
first load the html with submit button 2 disabled
echo '<input type="text" id="txtbox1" name="tb1" value="" />';
echo '<input type="submit" id="btn1" name = "btnstart" value="START" /><input type="submit" id="btn2" name = "btnend" value="End" disabled="disabled" />';
then using jquery
$(document).ready(function(){
$("input[type='submit']").click(function(){
$("input[type='submit']").prop('disabled',false);
$(this).prop('disabled',true);
});
});
disable the clicked submit button and enable other submit button
I placed an example in jQuery. jQuery is much easier then normal Javascript. Dont forget that jQuery is still javascript but then with functions that are already named to do their function:
.click() //When clicked
.next() //Next element/attribute
.mouseenter //When hover
.text() //Set the text
$('#mydiv').text('Contains this text');
Do the codecadamy.com training, its very helpfull, easy to follow and very quick.
I placed an example in jQuery for you:
JSFiddle
i am writing html form code with in php script
here it is
<?php
$problem_code="STR";
echo '<form name="submit-button" action="/codejudge/submit.php?id='.$problem_code.'">';
echo '<button type="submit" >Submit</button>';
echo "</form>";
?>
But after submitting url look like this localhost/codejudge/submit.php ?
but it should be like this localhost/codejudge/submit.php?id=STR
If a form is method="GET" (which is the default), as this one is, then submitting it will erase the existing query string in the action.
Store the data in a hidden input instead.
<?php
$problem_code="STR";
?>
<form name="submit-button" action="/codejudge/submit.php">
<input type="hidden" name="id" value="<?php echo htmlspecialchars($problem_code); ?>">
<button type="submit">Submit</button>
</form>
You should specify a method of form submit.
$problem_code="STR";
echo '<form method=post name="submit-button" action="/codejudge/submit.php?id='.$problem_code.'">';
echo '<button type="submit" >Submit</button>';
echo "</form>";
hi i have a check box and a button which opens a popup window on a button click i am sending a parameter which works fine now i have added a check box and i want to send its value as a parameter too and i am stuck here n have no idea of what has to be done
here is my script
<?php
if($addflag == 0){
echo "<td>";
echo '<font color="red"><strong>Print On Letter Head</strong></font><input type="checkbox" id="dtype" name="dtype" value="1" checked></input>';
echo '<input class="cmdprint" type="button" id="submit" name="print" value="Print" onclick="window.open(\'quotprin.php?vouchno='.$getvouch.'&dtype=\'document.getElementById(\'status1\').value;\'\',\'popUpWindow\',\'height=800,width=950,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes\');"></td>';
echo "<td>";
}
?>
somthing like this should work.
on suggestion try to avoid inline js and use functions instead.
other suggestion try to use checked="checked" instead of checked.
add this to javascript
<?php
if($addflag == 0){
echo '
<script type="text/javascript">
function mopen(){
var mobj=document.getElementById(\'dtype\');
var mval=mobj.value;
window.open(\'quotprin.php?vouchno='.$getvouch.'&dtype=mval\',\'popUpWindow\',\'height=800,width=950,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes\');
</script>
';
}
and the PHP
<?php
if($addflag == 0){
echo "<td>";
echo '<font color="red"><strong>Print On Letter Head</strong></font>
<input type="checkbox" id="dtype" name="dtype" value="1" checked="checked" />';
echo '<input class="cmdprint" type="button" id="submit" name="print" value="Print" onclick="mopen();"></td>';
echo "<td>";
}
?>
<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 '<input id="button" type="button" value="More"/>';
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://local.host/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
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?
<? echo '<input type=button onclick=\'window.location="companies.php?offset='. $next_offset .'"\'>';?>