/    Sign up×
Community /Pin to ProfileBookmark

queries are not excuting according to radio button

hi everyone
i am getting problem in this code
ths problem is :
there are two queries ,depending on radio button the queries willll exceute .everything is ok ,but only last query is exceuting ,my code is written below

i want :if user select a first radio button and click on the view button first query has to be diplayed or excuted .else if user selet second radio button and click the view button second query should be dipalyed .please help me

[code]
<SCRIPT LANGUAGE=JavaScript>
display()
{
somefunction();
check();
}

<FORM NAME=form1 method=post>
<input type=”radio” value=”1″ name=”Fee” checked= true>
<input type=”radio” value=”2″ name=”Fee” >
<input type=”submit” value=” View ” name=”B1″ onclick=”display();” >

function check()
{
if(document.form1.Fee[0].checked == true)
{
alert(document.form1.Fee[0].value);
<%

strsql1=”select * from buyer_master “;

// rs=statement.executeQuery(strsql1);
%>
}

else if(document.form1.Fee[1].checked == true)
{
alert(document.form1.Fee[1].value);
<%
strsql1=”select * from emd_master”;

// rs=statement.executeQuery(strsql1);

%>
}
}
out.print(strsql1);
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@driesaJul 25.2007 — hey not sure if this is what you looking for .....

an Example

you can maby strip the code so it can work for you ?
<i>
</i>&lt;html&gt;
&lt;title&gt;Radio Button Validation&lt;/title&gt;
&lt;body bgcolor="#FFFFFF"&gt;

&lt;script language="JavaScript"&gt;
&lt;!--
function op1_checker()
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter &lt; radio_form.op1.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (radio_form.op1[counter].checked)
radio_choice = true;
}

if (!radio_choice)
{
// If there were no selections made display an alert box
alert("Please make your selection.")
return (false);
}
return (true);
}

--&gt;
&lt;/script&gt;


&lt;form method="get" action="http://www.virtualcart.com/sc/cart.cgi"
onsubmit="return op1_checker()" name="radio_form"&gt;
&lt;input type="hidden" name="item" value="b-5167^ZZDA^DONATION to the AMMl^op1op2^1" /&gt;

&lt;input type="radio" value="25.00" name="op1"&gt;$25.00
&lt;br&gt;
&lt;input type="radio" value="50.00" name="op1"&gt;$50.00
&lt;br&gt;
&lt;input type="radio" value="75.00" name="op1"&gt;$75.00
&lt;br&gt;
&lt;input type="radio" name="op1"&gt;&lt;input type=text name=op2 size="20" /&gt;
(any amount not listed above)
&lt;br&gt;
&lt;input type="submit" value="Submit"&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@KorJul 25.2007 — Your page needs a [B]Doctype[/B] by all means.

http://www.w3.org/QA/2002/04/valid-dtd-list.html

http://htmlhelp.com/tools/validator/doctype.html

And the [I]language[/I] attribute is deprecated. Should be the [I]type[/I] instead.
<i>
</i>&lt;script type="text/javascript"&gt;
×

Success!

Help @saswat1579 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.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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