close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

javaScript to prevent form submit with 0 value

Thread began 1/18/2013 3:38 pm by Roxana | Last modified 1/20/2013 8:00 pm by Roxana | 6442 views | 9 replies


I opened a new thread about the warning, because it seems to have nothing to do with adding lines to the database.

This is how far I have gotten:

This code placed right behind the size drop down menu will echo "make a selection" when I try to add a $0 item to the cart, but it does not prevent the item from being added to the cart.

<span class="validation">
if ($row_rspricelookup['price'] == "0")
echo"<--", "&nbsp;", ($row_rscontent3['description5']);

With this code I successfully call a javascript function, when I hit submit (shortened for better viewing):

form action="Action" method="post" name="Name" id="ID" onsubmit="return checkForm();">

And this is the javascript function:

<script type="text/javascript">
function checkForm()
var prize = ($row_rspricelookup['price']);
if (prize == "0")
alert("Check size selection");
return false;

Not working. However when I leave out the variable and the if condition, the alert box will pop up instead of the page submitting. So I know, that the function is properly called, just the condition/variable is wrong.

I want to compare the current price to "0", but don't know how to incorporate the database value into the javascript function. ($row_rspricelookup['price']) worked for the php code, but not for the javascript.

Jason, could you tell me, how to call the value?

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...