Is it ok to write like this?
<input type="button" value="New booking" />
The link should look like a button but it should open in the right part of the page. If its wrong, is there any other way to do it?
The above code works fine. i just don't know if its the correct way to do it.
Thanks
No, this is not allowed according to the HTML5 specification.
The <button> element is considered "interactive content".
The <a> element must contain "no interactive content".
The button will probably show up, but since you're violating the specification it may not behave as you want. You should avoid doing this.
The most reliable to way to make a button bring the user to a page is to create a <form> that targets that page, and make the button submit that form.
<form action="add-lead-new.php"><input type="submit" value="New Booking" /></form>
no, the button itself wont do anything - it's only usefull with javascript to trigger any functions.
you should use css to make some of your links like a button: http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba
<input type="button" value="New booking" onclick="self.frames['rightframe'].location.href='add-lead-new.php'"/>
would be ok
It's better to just use CSS, but if you're really stuck on using a physical button, you can create a dummy form with no data:
<form action="href"><input type="submit" value="Click Here" /></form>
Yours is working but this is better,
<input type="button" value="New booking" onClick="top.frames['rightframe'].src='add-lead-new.php'" />
This is what worked for me.
<a><?php echo( "<button onclick= \"location.href='inc/name_of_php_file.php'\">your buttons name goes here</button>");?></a>
In other words nest your desired php code block inside an anchor element to 'link' it. Then add the php code block and inside that code block you'll want to add an echo(). Inside that echo you want to add your HTML code like normal. As if you weren't even writing in PHP.
Edit the folder name and file to your desired location. And then finally edit what text you want your button to show your viewers.
onclick= \"location.href='folder_name_goes_here/name_of_php_file_goes_here.php'\">your buttons name goes here
This should link to your page with your desired caption.
Please keep in mind the \" as this is utterly important. Without \ in front of the " your code wont read correctly due to the many "s found nested inside each other. \ allows HTML to ignore the first " as an end to the echo Sting.
Related
Currently I am using a hidden form (for reasons decided upon by others, not myself) to act as a link so it can post data with itself. This "link" always opens in the same window, and the general tricks I have tried don't let it open in a new tab instead. This is the current code, any tips?
<tr><td>
<form method="post" action="myPage.php" class="inline">
<input type="hidden" name="submit_parassmHidden" value="extra_submit_value">
<button type="submit" name=".$dataIAmPassingToNextPage." value="submit_value" class="link-button">"
.$linkTitle."</button></form>
</td>";
^Took out the escape slashes to be easier to read, its in PHP, its echo so it shows as regular HTML.
Things like target="_blank" dont seem to be working for me or I am putting them in the wrong place. Anyone have ideas on how I could do this?
EDIT: Since people are saying I can't be doing both, this is what I am doing. It LOOKS like a normal link, there is no form, it IS HIDDEN.
"Ok you're saying 2 different things here. The form is either hidden or you can see the submit link. Both can't be true" <- From comments. Clearly it is true, the form is hidden, and you can see the submit link. However I want these "Links" (which are really buttons in disguise) to open in the new tab.
Unfortunately you have not another option.
target="_blank" or button with formtarget="_blank" in HTML5 (like #CD001 comment) is the solution.
_blank Opens the linked document in a new window or tab depending on the user's browser configuration.
But I saw a little trick here: https://stackoverflow.com/a/15551850/2951051
someone who say to use target="_tab" even if not exist (I dont know if it really work)
<tr><td>
<form method="post" action="http://stackoverflow.com" class="inline" target="_blank">
<input type="hidden" name="input_name" value="extra_submit_value">
<button type="submit" name="form_name" value="submit_value" class="link-button">test</button></form>
</td>
I have a button in my html form that I want it to take user to food.php when they click on it, I did this but it's not redirecting, Please help
<a href="food.php">
<button name="submit" type="button" id="food">Food - Equipment</button>
</a>
Try this:
<button>Food - Equipment</button>
Why use a button element inside a link tag? Why not just:
Food - Equipment
Try that and see if it fixes it.
A button is requested, not a link. Sometimes linked php files don't work as expected in some browsers. Use a form submit button and you'll get what you're looking for.
<form action="food.php" method="GET"> <!-- use get or post if you want
to send anything -->
<input type="submit" value="GO">
</form>
I'm trying to find out how I can use $I->click with codeception for a button that shares the same name/value/type as another button on the same page. Examples are:
<input class="submit_btn uppercase" type="submit" name="go" value="/GO/"> // button I want to click
AND
<input class="submit_btn" type="submit" value="/GO/" name="go"> // button I don't want to click
What syntax should I use to delineate between the two? I've tried many different things including using the CSS locator after the button name like:
$I->click('go', '.uppercase'); // 2nd item is CSS locator
I've also tried:
$I->click('go', '.submit_btn uppercase'); // 2nd item is CSS locator
Firstly, I believe you should find a nearest parent tag that has id defined. I'll assume that there is a parent tag that has id="formId"
Here is the code to click that element by CSS selector:
$I->click('#formId > input.submit_btn.uppercase');
There is another way that you could click this element by xpath:
$I->click('//input[#class="submit_btn uppercase"]');
I'm not familiar with codeception, but if it has full CSS selector support (ambiguous to me after a quick look at their docs) you can look at using a :not(s) selector.
If that's the case, you should be able to use something like:
$I->click('go', '.submit_btn:not(.uppercase)');
For practice, on an html page, I have 2 buttons.
1 button was made using the tag, and it redirects to another page. (this works)
The second button, when pressed needs to display more features and options that populate the blank area of the page.
<?php
$action = (isset($_GET['sent'])) ? $_GET['sent'] : null;
If($action!=null){
?>
Other buttons go here, <b>Hello</b>
<?php
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'].'?sent=yes'; ?>" method="get">
<input type="submit" value="Show more buttons" />
</form>
Give or take that should do what you want to do. Although I recommend learning as this method is a little annoying as the entire contents of the page have to be refreshed. When dealing with text, it's not so bad, but most websites have images.
Try using CSS with javascript. Have the additional content in a separate div that is position:absolute and visibility:hidden. Attach javascript to the 2nd button, so that click changes visibility to visible.
I have made a small HTML search bar that is supposed to be capable of going to any page within the website. The only problem is, it won't leave that page, and if it does, it says the file is not found. Here is the code I have associated with it so far:
<form method="post" action="" name="search">
<input name="search" >
<button type="submit" name="Submit" onclick="window.location='http://localhost:8080/filefolder/<?php echo "'".$_POST[search]."'" ?>'">
Submit</button>
</form>
When you type anything into the search bar, and you click submit, the page just reloads and empties the search bar which is really frustrating.
So this is all that I have associated with the current search bar. What exactly am I doing wrong with it? I even added JavaScript telling the search button to send it to the page typed out. Can someone help me with this? Thank you.
Your code includes extra quotes which I don't believe you intended to have.
For example:
http://localhost:8080/filefolder/<?php echo "'".$_POST[search]."'" ?>'">
Is resulting in:
http://localhost:8080/filefolder/'search''">
As you can see this will break the javascript syntax when it tries to read that string.
Rewrite it as:
http://localhost:8080/filefolder/<?php echo $_POST['search'] ?>'">
Also add a return false to the end.
<button onclick="window.location.href='value_for_url'; return false;" />