I couldn’t find out how to make the button send FORM ~ and ALSO work as <a> LINK
I looked at W3Schools, HTMLGoodies, Tizag, and the top ten or 15 other ... sites; nothing really addresses this. The closest discussion I have found is the question "How best to make a link, submit the form" right here in StackOverflow, but this is a bit past my understanding at the moment.
Just with PHP and HTML, the work would be doable. Do you have something advanced in the last 3 years or is it still a matter of using JavaScript or some other language, and you need to go into the DOM for it to work?
In fact, I hate using one button to get the user in place on the desired page, then I need to press the second button to open the div with the content displayed. Most likely, they can click the View Comments button, and the page will go to the page and the contents will be visible.
The last 2 times I asked a question here, was good; in particular, I was very grateful. Hurrah! and if anyone has an answer, I would be very grateful to them for their help.
I could send 100 lines of code; a small demo, but it will hold. Also, I didn’t want to write out half a dozen or more things that I tried that were ineffective. :)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php error_reporting(E_ALL); $MeToo = mysql_connect('localhost','root','GuessHarder'); ?> <?php if (!$MeToo) {die ('What ~ ARE you a Novice? !!! ? : ' . mysql_error());} ?> <?php $InestimableUtility=99; ?> <html><Head><Title>YESH Link VIEWER</Title> <meta http-equiv="Content-Type" content="text/html; 06 charset=iso-8859-1 application/pdf text/plain text/css text/php "> <link rel="stylesheet" type="text/css" href="YESH Tha CSS.css"/><br /> <?php // 3 sets of catching POSTS and setting some Vars. $LINKfetched1=$_POST["1"]; $SleightOfHandx1= substr('\$LINKfetched1 ', 13); $LinkzFaithfulListener1=$_POST["NICExExplosions1"]; $NICExExplosions1=99; $LINKfetched2=$_POST["2"]; $SleightOfHandx2= substr('\$LINKfetched2 ', 13); $LinkzFaithfulListener2=$_POST["NICExExplosions2"]; $NICExExplosions2=99; $LINKfetched3=$_POST["3"]; $SleightOfHandx3= substr('\$LINKfetched3 ', 13); $LinkzFaithfulListener3=$_POST["NICExExplosions3"]; $NICExExplosions3=99; ?> </Head> <body id="Corpus"> <div id="LinkDisplayMAIN"> <div id="TopOfLinksContainDiv"> <div id="TitlePageLxDiv"><div id="LinkViewerTitleHerSELF"> The Links Viewer </div><!-- LinkViewerTitleHerSELF --></div><!-- TitlePageLxDiv --> </div><!-- TopOfLinksContainDiv --> <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><hr /> <pre> <br /><br /><a name="LinkItemDisplayDiv1">Link 1</a><br /><br /> <div id="AutoGenLINKxDIV1"><br /> <div id="ParamsTOPforLink1"><br /> <div id="DbLINKdataboxy1"><div id="abcLinkNum1"><?php echo ' '; ?>Link DB : Link # <?php echo "1"; ?></div><!-- abcLinkNum1 --></div><!-- DbLINKdataboxy1 --> <div id="AfterLinkNumSpacer1"></div> </div><!-- from ParamsTOPforLink1 --> <br /><br /><br /> <?php if($LinkzFaithfulListener1==99 and $InestimableUtility==99){ ?> <div id="YeahBabyShowThoseNotes1"> <div id="lameDivText1"> <?php echo "In the grand scheme of things, accept that um... you know, well."; ?><br /> </div><!-- lameDivText1 --> </div><!-- YeahBabyShowThoseNotes1 --><?php } ?> <div id="BottleFerButtonz1"> <div id="BttnOfLinkx1y1"><div id="Fake11"> <form action="<?php echo $PHP_SELF; ?>"; method="post"> <input type="hidden"name="NICExExplosions1"value="<?php echo $NICExExplosions1; ?>"/> <button type="submit">Show Notes About This Link</button></form> <a href="#LinkItemDisplayDiv1">Goto Link 1</a> </div><!-- from Fake11 --></div><!-- from BttnOfLinkx1y1 --> </div><!-- from BottleFerButtonz1 --><br /><br /></div><!-- from AutoGenDBdtrmndDIV1 --> </pre><hr /><br /><br /><br /> and a few more blocks, but that is the heart of the script; and some closing tags.
*** Following Day Edit by OP *** So, the sample block of code cleared is simple:
<pre> <a name="Anchored3"></a> <div id="AutoGenLINKxDIV3"> <div id="ParamsTOPforLink3"> <div id="DbLINKdataboxy3"><div id="abcLinkNum3"><?php echo' '; ?>Link DB: Link #<?php echo "3";?></div></div></div> <?php if($LinkzFaithfulListener3==99 and $InestimableUtility==99){?> <div id="YeahBabyShowThoseNotes3"> <div id="lameDivText3"> <?php echo "$someVariableRepresentingTextorImageOrContentofsometype";?><br /> </div></div><?php }?> <div id="BttnOfRelease3"><div id="FakeGetOuttaJail3"> <form action="<?php echo $PHP_SELF; ?>#Anchored3"method="post"> <?php $PayloadMeNow3=$DaGoodez3; ?> <input type="hidden"name="Liberte"value="<?php echo $Liberte; ?>"/> <input type="hidden"name="EveryDangStepNeedsAVariable3"value=" <?php echo $EveryDangStepNeedsAVariable3; ?>"/> <button type="submit">Return To Link Viewing</button></form> </div></div></pre> I misunderstood the question. The only way to submit the form without leaving the page is to submit it using ajax. So you would like to send it via ajax and then call everything you are trying to do, for example, open a div with the content displayed. see here http://www.simonerodriguez.com/ajax-form-submit-example/
<form name="MyForm" action="response_normal.php" method="post" onsubmit="xmlhttpPost('response_ajax.php', 'MyForm', 'MyResult', '<img src=\'pleasewait.gif\'>'); return false; YOURFUNCTIONHERE"> You will need to use javascript for this. Here is a possible way to backup it as a regular link:
Since you are talking about comments, I think that an example from a blog perspective would be most appropriate. Suppose your body looks like this:
<body> <h1>My blog post!</h1> <p>My content</p> <a href="http://site.com/blog/my-blog-post/comments/">View Comments</a> <div id="comments></div> </body> Here is what you can do:
If the user has javascript permission, use JQuery, YUI, or your favorite JS library to send a request to
http://site.com/blog/my-blog-post/comments/. Your server can determine if the request is an AJAX, send back an HTML fragment containing comments, and then paste it into thecommentsdiv.If the user does not have Javascript enabled, the user clicks a link to
http://site.com/blog/my-blog-post/comments/. The server can determine that thecommentsflag is in the link, so it will display the entire page, including comments.
That way, you can have a good AJAX download for users with javascript support and disconnect for users without JS.
The question was how to submit the form and the link to a specific place on the same page: with the caveat that this should be done with the click of a button. Not only stay on one page, but more or less on the same place on the page; do not find the page at the top after clicking to view additional information.
My problem was that I incorrectly thought that Goto XYZ is paired with an anchor Here: XYZ will be needed, and a lot of frustrations checking the various placements of these items made me worry that I would need some other mechanisms to achieve the goal of submitting the form, to control the opening of a div to display custom content but not to load the page at the top Also relevant was the desire to allow the user to press the close button to hide the div after viewing the content and not to open the page at the top again.
The solution was to detect a lot of trial and error, this simple bit of syntax:
<form action="<?php echo $PHP_SELF; ?>#Anchored3"method="post"> While this first Anchor 3 component is in place, another statement should not be in the script, and my experience was that it damaged most of the places where I tried to place it. One anchor is enough. How this happens, it's easy!
I also had a similar requirement, and the only solution I found was to use the form for the POST data in the same php file that the INSERT database does, process the post AND THEN data after that, using curl to extract the POST data / add more POST values and send them to another php file to send an email;
//send an email //extract data from the post $name = $_POST['fname']." ".$_POST['lname']; $email = $_POST['email']; $web = ""; $group_name = $_POST['group_name']; $message = ""; $username = $_POST['username']; $user_id = mysql_insert_id(); //point to script $url = 'scripts/emailer.php'; //set POST variables $fields = array( 'article_id'=>urlencode($article_id), 'name'=>urlencode($name), 'email'=>urlencode($email), 'web'=>urlencode($web), 'message'=>urlencode($message), 'username'=>urlencode($username), 'user_id'=>urlencode($user_id), 'group_name'=>urlencode($group_name), 'messagetype'=>'new_user' ); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $email_post = curl_init(); //set the url, number of POST vars, POST data curl_setopt($email_post,CURLOPT_URL,$url); curl_setopt($email_post,CURLOPT_POST,count($fields)); curl_setopt($email_post,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($email_post); //echo $result for testing //close connection curl_close($email_post); // end email approvers section