/    Sign up×
Community /Pin to ProfileBookmark

javascript in php

I am trying to make sure that both set of radio button are checked on submit.
I am using php and am having problems embeding JS in PHP. i did try but am having problems.
thanx for helping in advance.

[CODE]<?php
echo”<script type=”text/javascript”>”;
function checkBlank(){
if((!document.form1.apparel[0].checked && !document.form1.apparel[1].checked && !document.form1.apparel[2].checked && !document.form1.apparel[3].checked)
|| (!document.form1.material[0].checked && !document.form1.material[1].checked && !document.form1.material[2].checked){
echo”alert(“Select both categories”);”;
return false;
}
else{
return true;
}
}
echo”</script>”;
?>
[/CODE]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Stephen_PhilbinAug 09.2005 — Well by the looks of it you're missing a lot of stuff to be echo'd to the document. I can't see any point at all in echoing the Javascript either. So to me the solutions seems both very obvious and very simple: don't use PHP. Just exit PHP processing and then stick in the Javascript and then hop back into PHP when next you need.
Copy linkTweet thisAlerts:
@scriptKiddieauthorAug 09.2005 — yes but the form i am using echo's the html since i need to use data from the database.

how should i call this function from a form.
Copy linkTweet thisAlerts:
@scriptKiddieauthorAug 09.2005 — got it thanx
×

Success!

Help @scriptKiddie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...