Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 22nd, 2008, 09:36 PM
Authorized User
 
Join Date: Aug 2006
Location: , , .
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default put checked radio ID separated by a specified deli

halo there..need some help here..hope u all can help ya.
i got a list of radiobutton, with differnt name.
when i click on the radio button, it willpass the 'ID' into the JS function, how can i get the CHEKED radio ID and put in the hidden field first? i wan to put the all checked radio ID separated by a specified delimiter, such as in this format--> 1.2.3.4.5.6 with the delimiter '.'. can some one plz help me? thanx. bewlow is my html code :
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
    <title>Untitled Page</title>

</head>
<script language ="javascript">
function chkRadio()
{

    column =document.list_photo.hidCounter.value;
    var total = 0;
    var file =0;

    for(var i=1; i<=column; i++){
    var objId = "chkBuy" + i;
    var obj = eval("document.list_photo." + objId);
    document.list_photo.totalcredit.value = obj.length;
    for(var j=0; j<obj.length; j++){
    if(obj[j].checked && obj[j].value != 0){
    total += eval(obj[j].value);
    file++;
    }
    }
    }
    document.list_photo.total_file.value =file;
    document.getElementById('totalfile').innerHTML =file;
    document.getElementById('creditcost').innerHTML =total;

}


function chkPhoto(photoid)
{
alert(sizeid);
}


function chkValue()
{
    column =document.list_photo.hidCounter.value;
    var checked =false;
    if(document.list_photo.chkAgree.checked ==false)
    {
        alert("Please agree To terms");
        return false;
    }

    if(document.list_photo.total_file.value =="")
    {
            alert("Please select the images you wish to download.");
            return false;
    }
        document.list_photo.hidSubmit.value ="Submit";
        boxid =document.list_photo.hidboxid.value;
        document.list_photo.action ="lightbox_download.asp?boxid="+ boxid ;
        document.list_photo.submit();
}


</script>

<body>
<a href="list_lightbox.asp">List lightbox</a><br /><br />

<form name="list_photo" id="f1" method="post">
<table border="1">


    <tr>
        <td valign="top">IMAGE DISPLAY HERE</td>
        <td  valign="top"><a href ="">dog</a><BR /> alice</td>
        <td>

            <table>

                <tr>
                <td>XSmall&nbsp; - 100 x 100 px @ 72 Dpi  </td>
                <td>- 1Credit</td>
                <td><input type="Radio" name="chkBuy1" value="1" onClick="chkRadio();chkPhoto('1');" /></td>
                </tr>

                <tr>
                <td>Small&nbsp; - 200 x 280 px @ 72 Dpi  </td>
                <td>- 3Credits</td>
                <td><input type="Radio" name="chkBuy1" value="3" onClick="chkRadio();chkPhoto('1');" /></td>
                </tr>

                <tr>
                <td>Medium&nbsp; - 500 x 600 px @ 300 Dpi  </td>
                <td>- 5Credits</td>
                <td><input type="Radio" name="chkBuy1" value="5" onClick="chkRadio();chkPhoto('1');" /></td>
                </tr>

                <tr>
                    <td colspan="2" align="right">Skip This image file</td>
                    <td>
                    <input type="Radio" name="chkBuy1" value="0" onClick="chkRadio(this.value,'1')"  checked />
                    <input type="text" name="hiddX" value="1" size="5"/>
                    <input type="hidden" name="totalrecord1" value="" size="5"/>
                    </td>
                </tr>

            </table>
          </td>
    </tr>

    <tr>
        <td valign="top">IMAGE DISPLAY HERE</td>
        <td  valign="top"><a href ="">cat</a><BR /> lenny</td>
        <td>

            <table>

                <tr>
                <td>Small&nbsp; - 200 x 250 px @ 72 Dpi  </td>
                <td>- 3Credits</td>
                <td><input type="Radio" name="chkBuy2" value="3" onClick="chkRadio();chkPhoto('3');" /></td>
                </tr>

                <tr>
                <td>XSmall&nbsp; - 250 x 250 px @ 72 Dpi  </td>
                <td>- 1Credit</td>
                <td><input type="Radio" name="chkBuy2" value="1" onClick="chkRadio();chkPhoto('3');" /></td>
                </tr>

                <tr>
                    <td colspan="2" align="right">Skip This image file</td>
                    <td>
                    <input type="Radio" name="chkBuy2" value="0" onClick="chkRadio(this.value,'2')"  checked />
                    <input type="text" name="hiddX" value="2" size="5"/>
                    <input type="hidden" name="totalrecord2" value="" size="5"/>
                    </td>
                </tr>

            </table>
          </td>
    </tr>
 
    <tr>
        <td>
        <input type="text" name="photo" />


        </td>
    </tr>


 </table>

</form>
</body>
</html>
when i onclick the radio button, i call two function. the radio buttons value is loop from the Db so it has differnet name for every row. when i clicked on the radio button, one of the calling fucntion is chkPhoto('1')--> it will pass the photoid to the fucntion. if let say got three photo or more, how can i pass the value(assign it into the hidden text field name 'photo'? i would like to assign it in this format --> 1.2.3 with the delimiter join on the checked photo value.plz help
Reply With Quote
  #2 (permalink)  
Old January 28th, 2008, 05:39 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

HI Kumiko!!

hope this will help you
<script>
function check()
{
obj=document.all;
strVal=""
for(i=0;i<obj.length;i++)
{

if(obj[i].type=='radio')
 {
   if(obj[i].checked)
  {
  if(strVal=="")
     strVal+=obj[i].value
   else
     strVal=strVal+"."+obj[i].value
  }

 }
}
if(strVal!="")
{
document.getElementById("finalVal").value=strVal
}

}
</script>
<input type=button onclick="check()" value=getStatus>


<input type=radio name=rmm value=1>
<input type=radio name=rmm1 value=2>
<input type=radio name=rmm2 value=3>
<input type=radio name=rmm3 value=4>
<input type=text id="finalVal">

Cheers :)

vinod
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio Button[When it is checked] ashfaqshariff2007 Classic ASP Databases 1 October 15th, 2008 02:09 PM
check if a radio button has been checked crmpicco Javascript How-To 0 October 13th, 2005 09:53 AM
if radio button is checked crmpicco Javascript How-To 2 March 31st, 2005 05:10 PM
why not index.asp?id=1 can be www.myweb.com/?id=1 BurhanKhan Classic ASP Professional 11 September 6th, 2004 02:06 PM
My Radio Button is not checked goplayoutside VB.NET 2002/2003 Basics 4 May 8th, 2004 12:46 AM



All times are GMT -4. The time now is 12:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.