PShannon Posted December 20, 2020 Share Posted December 20, 2020 Here's what I have: $website = "https://shakingcrab.com/" (unquoted) <input type="url" id="website" name="website" value="<?php echo "<a href='$website'>Website</a>"; ?> "> This is what the HTML interpreter sees at execution: <input type="url" id="website" name="website" value="'https://shakingcrab.com/'>Website</a> "> Thanks . . . Link to comment Share on other sites More sharing options...
dsonesuk Posted December 20, 2020 Share Posted December 20, 2020 Why not use anchor link? To use a input you would need to add click event that run a function to get the url value from input, then use that url for redirect using location.href="http//:urladdress"; Link to comment Share on other sites More sharing options...
PShannon Posted December 20, 2020 Author Share Posted December 20, 2020 Because I am vested in: <input type="url" id="website" name="website" value="<?php echo "<a href='$website'>Website</a>"; ?> "> That's just one line of code from that form. There's a bunch of data in the form. Can you help me without suggesting other ways to accomplish this task? Here's how the Edge browser sees the statement at execution: <input type="url" id="website" name="website" value="'http://www.barracudatavern.com/'>Website</a> "> I know I'm close. Any ideas? I appreciate your input . . . Link to comment Share on other sites More sharing options...
dsonesuk Posted December 20, 2020 Share Posted December 20, 2020 (edited) You can't use anchor link within attribute value and expect to work, its treated just a string value, nothing more nothing less. The only option is as suggested grab url value and redirect using javascript Edited December 20, 2020 by dsonesuk Link to comment Share on other sites More sharing options...
PShannon Posted December 20, 2020 Author Share Posted December 20, 2020 Can you point me to some G2 on that? Thanks . . . Link to comment Share on other sites More sharing options...
dsonesuk Posted December 20, 2020 Share Posted December 20, 2020 https://www.w3schools.com/code/tryit.asp?filename=GLUYIZID0KYP Link to comment Share on other sites More sharing options...
PShannon Posted December 20, 2020 Author Share Posted December 20, 2020 Thank you . . . Link to comment Share on other sites More sharing options...
PShannon Posted December 21, 2020 Author Share Posted December 21, 2020 <input type="url" id="homepage" name="homepage" value="https://shakingcrab.com/"> <input type="button" onclick="triggerlink()" value="go to url"> This is on the right track, but I do not have the value of the target. The value of the target is in a variable, $website. How does the <input> statement change, given that? You can see what I am trying to do here: http://www.database39.com/page.php?id=13 (cursor down, below image) I appreciate you responding. I've been struggling with this for some time . . . Link to comment Share on other sites More sharing options...
dsonesuk Posted December 21, 2020 Share Posted December 21, 2020 Use a valid url in input value, it will break if contains the exta apostrophe at beginning and the '</a>', if you copy to address bar and after hitting go and it shows an error, obviously its not valid. Once that is sorted the clicking of added button 'go to url, a function will retrieve the now valid url then redirect to it you need to change var x = document.getElementById("homepage"); to var x = document.getElementById("website"); Link to comment Share on other sites More sharing options...
dsonesuk Posted December 21, 2020 Share Posted December 21, 2020 <input type="url" id="website" name="website" value="https://www.marielofficial.com/"> <br> <input type="button" onclick="triggerlink()" value="go to url"> <br> <script> function triggerlink(){ var x = document.getElementById("website"); window.location.href=x.value; } </script> Link to comment Share on other sites More sharing options...
PShannon Posted December 22, 2020 Author Share Posted December 22, 2020 (edited) This works! You're a bloody genius! I have been chasing this for weeks. Thank you! I could use some help cleaning it up a bit. If you look at the resulting webpage -- http://www.database39.com/page.php?id=17 -- the code produces two rows. The first row contains https://www.110grill.com/ The second, "action," row contains the legend "Website" Can the first row be made to "go away?" Again, I am very grateful. Edited December 22, 2020 by PShannon I have eleven thumbs. Link to comment Share on other sites More sharing options...
dsonesuk Posted December 22, 2020 Share Posted December 22, 2020 Is this data entered dynamically from database? then i don't know why the form, if not! And it is all done manually, then you need the website input to be showing all the time, so someone can add/amend the website and can be submitted. Link to comment Share on other sites More sharing options...
PShannon Posted December 22, 2020 Author Share Posted December 22, 2020 Forgive my omission. I should have identified the source up front. My bad! The target URL is stored in a MySQL database as a VARCHAR field in the "bars" table. The target "bar" is selected via a series of drop-downs -- also sourced from MySQL tables -- that answer the questions: What neighborhood do you want? Do you want a bar or a club/hotel/restaurant bar? Select from list of bars/clubs/hotels/restaurants in "neighborhood." Here's a page that shows a "selected" bar and demonstrates the application (cursor down to below image). http://www.database39.com/page.php?id=519 Again, I am extremely grateful for your consult. I can live with what you have provided, but if it can be polished that last bit by ridding the "URL/link" row above the "action" tab, that would be superb. Link to comment Share on other sites More sharing options...
dsonesuk Posted December 22, 2020 Share Posted December 22, 2020 Then why not just add the url to a type hidden input, if not supposed to be edited, you could then just add the url to an anchor link with url in href attribute and innerHTML of that anchor link with target attribute value of '_blank', this requires no javascipt as everything required is dynamically added by database. Link to comment Share on other sites More sharing options...
PShannon Posted December 22, 2020 Author Share Posted December 22, 2020 I really hate to be a pain in the , amigo, but could you show me what that would look like -- please! Link to comment Share on other sites More sharing options...
dsonesuk Posted December 23, 2020 Share Posted December 23, 2020 <!-- All url generated dynamically from database table column holding website url --> <input type="hidden" id="website" name="website" value="https://www.marielofficial.com/"> <br> <a href="https://www.marielofficial.com/" target="_blank">https://www.marielofficial.com/</a> Link to comment Share on other sites More sharing options...
PShannon Posted December 23, 2020 Author Share Posted December 23, 2020 I can live with this. http://www.database39.com/page.php?id=701 Thank you . . . enjoy the holidays . . . Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now