searls03 Posted February 29, 2012 Share Posted February 29, 2012 Ok, so what is happening is my form submits to this: <body> <?php // load Zend Gdata libraries require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_Spreadsheets'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); // set credentials for ClientLogin authentication $user = "user"; $pass = "password"; try { // connect to API $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); $service = new Zend_Gdata_Spreadsheets($client); // set target spreadsheet and worksheet $ssKey = 'ssKey'; $wsKey = 'wsKey'; $name='Aaron Searls'; $item= "".$_POST['item']."".$_POST['item1'].""; // create row content $row = array( "date" => date('m-d-y'), "name" => $name, "item" => $item, "paid" => 'yes' ); // insert new row $entryResult = $service->insertRow($row, $ssKey, $wsKey); } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } echo $name; echo $item; ?> <?php echo 'aaron'; echo $item; ?> </body> <html> This is the form: <form method="POST" name="myform<?php echo $id; ?>" id="myform<?php echo $id; ?>"> <?php if ((strpos($val,'Sparring') || strpos($val,'Feet')) !== false){ ?> <input name="item" type="hidden" value="Sparring Feet Size: " /> <select name="item1"> <option idue="Child 12/13">Child 12/13</option> <option value="1/2">1/2</option> <option value="3/4">3/4</option> <option value="5/6">5/6</option> <option value="7/8">7/8</option> <option value="9/10">9/10</option> <option value="11/12">11/12</option> <option value="13/14">13/14</option> </select> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Hands')) !== false){ ?> <input name="item" type="hidden" value="Sparring Hands...shoe size: " /> please enter shoe size(hands are based on shoe size) <input name="item1" type="text" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Shins')) !== false){ ?> <input name="item" type="hidden" value="Sparring shins...shoe size:" /> please enter shoe size(shins are based on shoe size) <input name="item1" type="text" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'head')) !== false){ ?> <input name="item" type="hidden" value="Sparring Head: size" /> please keep in mind most people are XL <select name="item1"> <option value="Small">Small</option> <option value="Medium">Medium/Lg</option> <option value="Large">X-Large</option> </select> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Elbow Pads')) !== false){ ?> <input name="item" type="hidden" value="elbow pads" /> <?php } else if ((strpos($val,'Sparring') || strpos($val,'Groin Protector')) !== false){ ?> <input name="item" type="hidden" value="Groin protector size: " /> <select name="item1"> <option value='Child Cup Sm (20"-26")'>Child Cup Sm (20"-26")</option> <option value='Child Cup Lrg (26"-32")'>Child Cup Lrg (26"-32")</option> <option value='Adult Small (26"-32")'>Adult Small (26"-32")</option> <option value='Adult Medium (32"-38")'>Adult Medium (32"-38")</option> <option value='Adult Large (38"-44")'>Adult Large (38"-44")</option> <option value='Adult X-Large (44"-50")'>Adult X-Large (44"-50")</option> </select> <?php } else if ($val=='Sparring/Ecas Gear:ECAS Gear'){ ?> <input name="item" type="hidden" value="Ecas Gear size " /> Shin/elbow <select name="shin/elbow"> <option value="Small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option> <option value="X-Large">X-Large</option> </select> Shin/elbow <select name="glove"> <option value="Sm/Med">Sm/Med</option> <option value="Lg/Xl">Lg/Xl</option> </select> <?php } ?> <input type="submit" name="hellobob" value="Submit" /> </form> The code submits to ajax without a page refresh. After it submits to the ajax which submits to the first code, I want the submit button and the form field to turn into a message saying submitted. How do I do this? does this make sense? Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/ Share on other sites More sharing options...
creata.physics Posted February 29, 2012 Share Posted February 29, 2012 Yes it makes sense, but it isn't a php issue. It would most likely require javascript as you want the submit buttons state to change on that page without refreshing it. Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322197 Share on other sites More sharing options...
searls03 Posted February 29, 2012 Author Share Posted February 29, 2012 so there is no way to do an if isset type of thing, then a message appears? do you have any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322266 Share on other sites More sharing options...
Drongo_III Posted February 29, 2012 Share Posted February 29, 2012 Not sure you could use isset() because you're not refreshing the page and so not parsing anything. You're best option is probably to fire a javascript function (onsubmit) that will hide the form and display your message. Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322270 Share on other sites More sharing options...
searls03 Posted February 29, 2012 Author Share Posted February 29, 2012 could you supply an example? Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322272 Share on other sites More sharing options...
Drongo_III Posted February 29, 2012 Share Posted February 29, 2012 Hi Mate Probably easiest if done with jquery. Something like: <script> $(document).ready(function () { $("#FormSubmitButtonID").click(function(){ // Logic to determine the form is ok to submit. $('#YourFormID').hide(); $("#YourThankYouMessageDivID").show(2000); }); }); </script> Tapping that in off the top of my head, and i always typo javascript, but it is a simplistic example of what you want. Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322275 Share on other sites More sharing options...
searls03 Posted February 29, 2012 Author Share Posted February 29, 2012 how do I hide the thank you div by default? Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322277 Share on other sites More sharing options...
Drongo_III Posted February 29, 2012 Share Posted February 29, 2012 Or a maybe a better way might be to use a callback functino call from your AJAX to call a function that does the above. Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322278 Share on other sites More sharing options...
Drongo_III Posted February 29, 2012 Share Posted February 29, 2012 Just set the thank you div style to display:none; how do I hide the thank you div by default? Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322280 Share on other sites More sharing options...
searls03 Posted February 29, 2012 Author Share Posted February 29, 2012 but won't that hide it even when the script tells it to show? Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322281 Share on other sites More sharing options...
Drongo_III Posted February 29, 2012 Share Posted February 29, 2012 Nop - jquery will reset the style and unhide it when the function is called. Jquery is like magic but won't that hide it even when the script tells it to show? Quote Link to comment https://forums.phpfreaks.com/topic/257954-feed-back-after-form/#findComment-1322284 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.