CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Need help with simple javascript

 



datlaravi
Deleted

Dec 6, 2000, 8:10 AM

Post #1 of 3 (363 views)
Need help with simple javascript Can't Post

 HI,

I have a form which displays 3 radio buttons. Code for it is

$html .= "<TD><FONT COLOR=\"#0000FF\">10. Opportunity Type: </FONT> </TD>\n";
$html .= "<TD>\n";
$html .= "<INPUT TYPE=\"radio\" NAME=\"Opptype\" VALUE=\"1\">Upgrade-Add Minor<BR> \n";
$html .= "<INPUT TYPE=\"radio\" NAME=\"Opptype\" VALUE=\"2\">Upgrade-Add Major <BR>\n";
$html .= "<INPUT TYPE=\"radio\" NAME=\"Opptype\" VALUE=\"3\">Upgrade-Add Significant <BR>\n";
$html .="</TD></TR>\n";
print $html;

Output of the above code is
10. Opportunity Type: Upgrade-Add Minor
Upgrade-Add Major
Upgrade-Add
Significant

Radio buttons are displayed infront of the each type.
If the user checks the radio button, the output is displayed like the below
with the submit button.
10. Opportunity Type: Upgrade-Add Minor
Upgrade-Add Major
(CHECKED) Upgrade-Add Significant.

Submit

Code for the above output is

if( $contents{Opptype} == 1) {
$FIR=CHECKED;
}

if( $contents{Opptype} == 2) {
$TWO=CHECKED;
}
if( $contents{Opptype} == 3) {
$THREE=CHECKED;
}
if( $contents{Opptype} == 4) {
$FOUR=CHECKED;
}
if( $contents{Opptype} == 5) {
$FIVE=CHECKED;
}
$html .="<TR>\n";

$html .= " <TD><FONT COLOR =\"#0000FF\">8. Opportunity Type:</FONT> </TD>\n";
$html .= " <TD><INPUT NAME=\"NOpptype\" SIZE=\"25\" TYPE=\"radio\" VALUE=\"FIR\"$FIR>Upgrade -Add Major<br>\n";
$html .= " <INPUT NAME=\"NOpptype\" SIZE=\"25\" TYPE=\"radio\" VALUE=\"TWO\"$TWO>Upgrtade Add-Minor <br>\n";
$html .= " <INPUT NAME=\"NOpptype\" SIZE=\"25\" TYPE=\"radio\" VALUE=\"THREE\"$THREE>Upgrade - Add Significant<br>\n";
$html .= "</TR>\n";
$html .= "<input type = "submit" name = "button1" value ="Submit" OnClick = \"calc()\"\n";

I need help in calc() function.

How do i know that NOpptype['THREE'] is checked.

I want to display the alertbox if NOpptype['THREE'] is checked.

$html .= "function calc() { \n";

$html .= " if(document.forms.['main'].NOpptype['THREE'].checked) {\n";
$html .= " alert("radio button is checked")\n" } ";

I am getting error at NOpptype['THREE'].

I don't know how to get the already checked radio button.

Please help me with this. Let me know if it is not clear

Thanks


datlaravi
Deleted

Dec 5, 2000, 10:08 PM

Post #2 of 3 (363 views)
Re: Need help with simple javascript [In reply to] Can't Post

Hi Sleuth,

You got the problem and you solved it.

Thanks a lot.

Have a good day.


sleuth
Enthusiast

Dec 6, 2000, 9:35 AM

Post #3 of 3 (363 views)
Re: Need help with simple javascript [In reply to] Can't Post

 
I sort of see what you need, java script wise,

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>
How do i know that NOpptype['THREE'] is checked.

I want to display the alertbox if NOpptype['THREE'] is checked.
<HR></BLOCKQUOTE>

use this

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


<script language="javascript">
<!--
function calc(){
var radio = document.FORM.NOpptype[2].checked;
var radio_data = document.FORM.NOpptype[2].value;
if (radio == true){
var message = "The Radio Button Three Is Checked";
alert(message);
}
}
//-->
</script>
</pre><HR></BLOCKQUOTE>

Sleuth

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives