Jump to content

Reload page with new data using a form.


mike12255

Recommended Posts

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>

 

 

Link to comment
https://forums.phpfreaks.com/topic/148417-reload-page-with-new-data-using-a-form/
Share on other sites

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();
});


});

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.