Jump to content

Recommended Posts

Thanks for that help,

 

can you tell me how to be able to prevent the form from submitting without having a box ticked. Ive tried some code but having trouble getting it to work...

  <FORM NAME="priceForm" method="post" action="goodbye.php">
      <P/>
      <TABLE>
      <TR>
      <TD></TD>
      	<TD></TD>
      <TD>Price(£)</TD>
      </TR>
      <TR>
      <TD><INPUT TYPE="checkbox" NAME="Markets" VALUE="Aviation and Aerospace"
      	      onClick="showPrices(1)"></INPUT></TD>
      <TD>Aviation and Aerospace</TD>
      	<TD><INPUT TYPE="text" NAME="AviationField" SIZE="5" VALUE=""></INPUT></TD>
      </TR>
      <TR>
      <TD><INPUT TYPE="checkbox" NAME="Markets" VALUE="Banks"
      	      onClick="showPrices(2)"></INPUT></TD>
      <TD>Banks</TD>
      	<TD><INPUT TYPE="text" NAME="BanksField" SIZE="5" VALUE=""></INPUT></TD>
      </TR>
       <TR>
      <TD><INPUT TYPE="checkbox" NAME="Markets" VALUE="Construction"
      	      onClick="showPrices(3)"></INPUT></TD>
      <TD>Construction</TD>
      	<TD><INPUT TYPE="text" NAME="ConstructionField" SIZE="5" VALUE=""></INPUT></TD>
      </TR>
      <TR>
      <TD><INPUT TYPE="checkbox" NAME="Markets" VALUE="Electronics"
      	      onClick="showPrices(4)"></INPUT></TD>
      <TD>Electronics</TD>
      	<TD><INPUT TYPE="text" NAME="ElectronicsField" SIZE="5" VALUE=""></INPUT></TD>
      </TR>
      <TR>
      <TD><INPUT TYPE="checkbox" NAME="Markets" VALUE="Oil and Gas"
      	      onClick="showPrices(5)"></INPUT></TD>
      <TD>Oil and Gas</TD>
      	<TD><INPUT TYPE="text" NAME="OilandGasField" SIZE="5" VALUE=""></INPUT></TD>
      </TR>
      <TR>
      <TD><INPUT TYPE="checkbox" NAME="Markets" VALUE="Pharmaceuticals"
      	      onClick="showPrices(6)"></INPUT></TD>
      <TD>Pharmaceuticals</TD>
      	<TD><INPUT TYPE="text" NAME="PharmaceuticalsField" SIZE="5" VALUE=""></INPUT></TD>
      </TR>
      
<TR>
      <TD></TD>
      	<TD>Total:</TD>
      <TD><INPUT TYPE="text" NAME="TotalField" SIZE="5" VALUE="0"></INPUT></TD>
      </TR>
      </TABLE>
      <p>
  <input type="submit" name="submit" value="Subscribe">
    </FORM>

 

Link to comment
https://forums.phpfreaks.com/topic/233492-help-with-preventing-to-submit/
Share on other sites

There is probably a better way that checks all boxes, but this will work:

 

Change

onClick="showPrices(2)">

For every box to show this

onClick="changebox();showPrices(1);"></TD>

 

Then add this js

function changebox() {
document.getElementById('SelectButton').style.display = "block";
}

 

This css

#SelectButton{
display:none;
}

 

And add this div to the select button

<div id="SelectButton">
  <input type="submit" name="submit" value="Subscribe">
</div>

 

PS. Your <INPUT does not need a </INPUT> tag.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.