Jump to content

Submit Onlick form


Recommended Posts

I have a php/html page that enables me to update delete and add new jobs to my database. depending on what function i want the page to do i select the relevant radio button (update,delete,add) and hit a form submit button. It then carries out the function i want it to.<input type="submit" value=" Do it " />I am trying to change the appearance of my form submit button by using a combination of javascript and css.<a href="" onclick="record_mod.submit()" class="button" span class="icon"> Submit </span><a>The button now looks how i want it to but i have lost its functionality as it doesnt seem to be working with the radio buttons anymore.Below is my form code. can anyone shed on light on what im doing wrong?Many thanks

<form name=\"record_mod\" method=\"post\" action=\"jobadmin.php\"><table border=\"1\" width=\"750\" cellspacing=\"0\" cellpadding=\"0\">  <tr>	<td>	  <table border=\"0\" width=\"750\" cellspacing=\"0\" cellpadding=\"0\">		<tr>		  <td align=\"left\">JobID: {$row['JobID']}</td>		</tr>	  </table>			  <table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">		<tr>		  <td width=\"75\" align=\"right\">Start Date:</td>		  		  <td colspan=\"3\">		  		  <input id=\"demo3\" type=\"text\" name=\"StartDate\" size=\"25\" value=\"{$row['StartDate']}\">  		  <a  href=\"java script:NewCal('demo3','ddmmyyyy')\"><img  src=\"cal.gif\" width=\"16\"  height=\"16\" border=\"0\"></a>		  					  		</tr>		<tr>		  <td width=\"75\" align=\"right\">End Date:</td>		  <td><input id=\"demo4\" type=\"text\" name=\"EndDate\" size=\"25\" value=\"{$row['EndDate']}\">  		  <a  href=\"java script:NewCal('demo4','ddmmyyyy')\"><img  src=\"cal.gif\" width=\"16\"  height=\"16\" border=\"0\"></a></td></tr>		  <td>Job Address 1:</td>		  		  <td><input name=\"JobAddress1\" type=\"text\" size=\"30\" maxlength=\"20\" value=\"{$row['JobAddress1']}\" /></td>		   <td>Job Address 2:</td>		  <td><input name=\"JobAddress2\" type=\"text\" size=\"30\" maxlength=\"20\" value=\"{$row['JobAddress2']}\" /></td>		</tr>	  </table>	  <table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">		<tr>		  <td width=\"75\" align=\"right\">Postcode:</td>		  <td><input name=\"JobPostcode\" type=\"text\" size=\"40\" maxlength=\"25\" value=\"{$row['JobPostcode']}\" /></td>		</tr>		<tr>		  <td width=\"75\" align=\"right\">Price :</td>		  <td><input name=\"Price\" type=\"text\" size=\"40\" maxlength=\"25\" value=\"{$row['Price']}\" /></td>		</tr>	  </table>	  <table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">		<tr>		  <td width=\"75\" align=\"right\">Description:</td>		  <td><input name=\"Description\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['Description']}\" /></td>		  <td>Materials:</td>		  <td><input name=\"Materials\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['Materials']}\" /></td>	   <td>Customer Id:</td> 	   	   <td><input name=\"cid\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['cid']}\" /></td>		<tr> <td>First Name:</td> 		<td><input name=\"first_name\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['first_name']}\" /></td></tr><td>surname:</td> 		   <td><input name=\"surname\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['surname']}\" /></td>	 <td>Paid<input name =\"paid\" type=\"checkbox\" value=\"{$row['paid']}\" /></td>	 	 	   	   	  </table>	 	  <hr align=\"left\" width=\"650\">	  <table border=\"0\" width=\"750\" cellspacing=\"0\" cellpadding=\"0\">		<tr>		  <td align=\"left\">Process</td>		</tr>	  </table>	  <table border=\"0\" cellspacing=\"2\" cellpadding=\"4\">		<tr>		  <td><input name=\"op\" type=\"radio\" value=\"1\" /> Update Record</td>		  <td><input name=\"op\" type=\"radio\" value=\"2\" /> New Record</td>		  <td><input name=\"op\" type=\"radio\" value=\"3\" /> DELETE Record</td>		</tr>	  </table>	  <table border=\"0\" cellspacing=\"2\" cellpadding=\"4\">		<tr>		  <td colspan=\"3\"><input type=\"submit\" value=\" Do It ! \" /></td>		  <td><a href=\"jobs.php\" class=\"button\" span class=\"icon\"> Records List </span></a></td>	  		  <td><a href=\"jobadmin.php?JobID=0&op=4\" class=\"button\" span class=\"icon\"> Synchronize</span></a></td>		   <td style=\"padding-left: 50px;\">		   <td> <a href=\"jobadmin.php?JobID=$JobID&op=5&move=2\" class=\"button\" span class=\"icon\">Previous</span></a></td><td>Navigate			 <td> <a href=\"jobadmin.php?JobID=$JobID&op=5&move=1\" class=\"button\" span class=\"icon\">Next</span></a></td>		  </td>		  <td><a href=\"invoice.php?JobID={$row['JobID']}\" class=\"button\" span class=\"icon\"> Create Invoice </span></a></td> 		</tr>	  </table>	</td>  </tr></table></p><input name=\"JobID\" type=\"hidden\" value=\"$JobID\" /></form>"

Link to post
Share on other sites
<a href="" onclick="record_mod.submit()" class="button" span class="icon"> Submit </span><a>
I think you're going to need:
<a href="java script:document.getElementById('record_mod').submit()" class="button" span class="icon"> Submit </span><a>

Note: javascript is one word, not two. This forum splits it into two when sample code is posted, but it won't work like that!

Link to post
Share on other sites

Thanks for your reply, it was worth a shot but it still didnt work! Any other suggestions?

I think you're going to need:
<a href="java script:document.getElementById('record_mod').submit()" class="button" span class="icon"> Submit </span><a>

Note: javascript is one word, not two. This forum splits it into two when sample code is posted, but it won't work like that!

Link to post
Share on other sites

I'm not sure this will help with the offending problem, but this should be noted. This...

<a href="java script:document.getElementById('record_mod').submit()" class="button" span class="icon"> Submit </span><a>

Should be more like this...

<a href="java script:document.getElementById('record_mod').submit()" class="button"><span class="icon">Submit</span><a>

I think you simply forgot to conclude the <a> tag before you started the span tag. Since you highlighted this as being what you deemed to be giving you troubles, check if this revision works. Also, it seems you've done this with a lot of <a> tags too, so it probably is much more than one line of code.

Link to post
Share on other sites
Thanks for your reply, it was worth a shot but it still didnt work! Any other suggestions?
Ah, yes: I see your form has no id! So it won't be found by getElementById().This
<form name=\"record_mod\" method=\"post\" action=\"jobadmin.php\">

needs to become

<form name=\"record_mod\" id=\"record_mod\" method=\"post\" action=\"jobadmin.php\">

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...