mike12255 Posted March 8, 2009 Share Posted March 8, 2009 I got a form on a page (ill post code below) and it has two buttons a Preview button, and a submit button i know how to setup the submit button, but i want the Preview button to reload the page and put the info the in the text boxes to variables, but i dont know how to go about it, heres my form: <table width="780" border="0" cellpadding="5" cellspacing="5"> <tr> <td><div align="center"></div></td> </tr> <tr bgcolor="#E6E6E6"> <td height="138" align="center"><div align="center" class="style1"><html> <title>Registration Page</title> <body> <h1>Stayner.ca Buisness Register</h1> <p><br /> </p> <form id="form1" name="form1" method="post" action="index.php"> <table border="0" align="left" cellpadding="3" cellspacing="0"> <tr> <td>Buisness Name:</td> <td><input name="name" type="text" id="name" value="<? echo $form->value("user"); ?>" maxlength="30" /></td> </tr> <tr> <td>Buisness Adress:</td> <td><input name="adress" type="text" id="adress" value="<? echo $form->value("pass"); ?>" maxlength="30" /></td> </tr> <tr> <td> Contact Email:</td> <td><input name="email" type="text" id="email" value="<? echo $form->value("email"); ?>" maxlength="50" /></td> </tr> <tr> <td> Contact Phone:</td> <td><input name="phone" type="text" id="phone" value="<? echo $form->value("email"); ?>" maxlength="50" /></td> </tr> <tr> <td>Website:</td> <td><input name="website" type="text" id="website" value="<? echo $form->value("email"); ?>" maxlength="50" /></td> </tr> </table><p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <label> <input type="submit" name="preview" id="preview" value="Preview Display" /> </label> <label> <input type="submit" name="submit" id="submit" value="Submit Buisness" /> </label> </form> <p> </p></td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
Rodis Posted March 8, 2009 Share Posted March 8, 2009 I think you should use a piece of jquery to have different buttons to different things and have the preview button take action to the preview field like so <form id="myForm" method="post"> Search: <input type="text" name="search"/> <input type="button" id="preview" value="Preview display" /> <input type="button" id="submit" value="Submit buisness" /> </form> $(document).ready(function(){ $("#preview").click(function(){ $('form#myForm').attr({action: "preview.php"}); $('form#myForm').submit(); }); $("#submit").click(function(){ $('form#myForm').attr({action: "submitpage.php"}); $('form#myForm').submit(); }); }); Quote Link to comment Share on other sites More sharing options...
mike12255 Posted March 8, 2009 Author Share Posted March 8, 2009 do people not need javascript enabled for that to work? I know there is a way to do this in php i've seen this done before. - i dont know any jquery. Quote Link to comment Share on other sites More sharing options...
Rodis Posted March 8, 2009 Share Posted March 8, 2009 I wouldn't know any other way to get it to work as either with javascript or jquery. And as for as my knowledge goes, aren't form attributes part of javascript to? jquery just makes javascript shorter and looks better? at least it is working for me on some pages i used. correct me if i am wrong Quote Link to comment Share on other sites More sharing options...
mike12255 Posted March 8, 2009 Author Share Posted March 8, 2009 I was not saying your wrong, i was taking a guess, im not sure how exactly to do this and almost nothin on jquery and javascript. Ill try it though Quote Link to comment 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.