/    Sign up×
Community /Pin to ProfileBookmark

help display value of selected radio button

i am making an application on my website using javascript and html. i
have knowledge in php and html, but not much at all in javascript. the
application is split up by div tabs and inside the tabs is a list of
different links to other div tags that have radio button groups inside
them. im sure this is very basic but i want the value of the selected

radio button to be displayed in a table on that same page. so if someone select option 1, it would display option 1’s value in the table at the bottom of the page. I know i could do this in php when i submit the form but I need the application to not need to refresh the page if possible. Below is a link to where i have the application and here is the code. any help is greatly
appreciated. thank you very much in advance!
[url]http://rangoliflowers.com/tabs/yetti.html[/url]

<html>

<head>
<script type=”text/javascript” src=”yetii.js”></script>

<style type=”text/css”>
<!–
#apDiv1 {
position:absolute;
width:335px;
height:48px;
z-index:1;
left: 211px;
top: 106px;
}
ul li {
list-style: none;
list-style-image: url(/images/invisiblebullet.gif);
}
img {
border: 0;
}
#apDiv2 {
position:absolute;
width:587px;
height:115px;
z-index:1;
left: 199px;
top: 43px;
}
–>
</style>

</head>

<body>
<div id=”apDiv2″>
<div id=”tab-container-1″>
<ul id=”tab-container-1-nav”>
<li class=”activeli”><a class=”active” href=”#tab1″></a></li>
<li class=”activeli”><a class=”active” href=”#tab2″></a></li>
<li class=”activeli”><a class=”active” href=”#tab3″></a></li>
<li class=”activeli”><a class=”active” href=”#tab4″></a></li>
<li class=”activeli”><a class=”active” href=”#tab5″></a></li>
<li class=”activeli”><a class=”active” href=”#tab6″></a></li>
<li class=”activeli”><a class=”active” href=”#tab7″></a></li>
<li class=”activeli”><a class=”active” href=”#tab8″></a></li>
<li class=”activeli”><a class=”active” href=”#tab9″></a></li>
</ul>

<!– MAIN TABS –>
<a href=”#tab1″ onclick=”tabber1.show(1); return false; “>tab 1</a>&nbsp;
<a href=”#tab2″ onclick=”tabber1.show(2); return false;”>tab 2</a> &nbsp;
<a href=”#tab3″ onclick=”tabber1.show(3); return false;”>tab 3</a> &nbsp;
<a href=”#tab4″ onclick=”tabber1.show(4); return false;”>tab 4</a>&nbsp;

<div class=”tab” id=”tab1″>
<br>
<br>
<a href=”#tab5″ onclick=”tabber1.show(5); return false;”> link to div tag 1 <br/></a>
<a href=”#tab6″ onclick=”tabber1.show(6); return false;”> link to div tag 2 <br/></a>
<a href=”#tab7″ onclick=”tabber1.show(7); return false;”> link to div tag 3 <br/></a>
<a href=”#tab8″ onclick=”tabber1.show(8); return false;”> link to div tag 4 <br/></a>
<a href=”#tab9″ onclick=”tabber1.show(9); return false;”> link to div tag 5 <br/></a>
</div>

<!– START OF MAIN TABS –>
<div class=”tab” id=”tab2″>
<p>this would be pretty much the same as the first tab, just different links to different radio button groups </p>

</div>

<div class=”tab” id=”tab3″>
<p> this would be pretty much the same as the first tab, just different links to different radio button groups </p>

</div>

<div class=”tab” id=”tab4″>
<p> this would be pretty much the same as the first tab, just different links to different radio button groups </p>

</div>
<!– END OF MAIN TABS –>
<!– INDIVIDUAL PART TABS –>
<!– FIRST TAB –>
<div class=”tab” id=”tab5″>

<form name=”parts” action=” just a page to process the data ” method=”POST”>
<br>
<br>
<input type=”radio” name=”1″ value=”option 1″> option 1<br>
<input type=”radio” name=”1″ value=”option 2″> option 2<br>
<input type=”radio” name=”1″ value=”option 3″> option 3<br>

<a href=”#tab1″ onclick=”tabber1.show(1); return false; “> Back</a>
</div>

<div class=”tab” id=”tab6″>

<br>
<br>
<input type=”radio” name=”2″ value=”option 1″> option 1<br>
<input type=”radio” name=”2″ value=”option 2″> option 2<br>
<input type=”radio” name=”2″ value=”option 3″> option 3<br>

<a href=”#tab1″ onclick=”tabber1.show(1); return false; “> Back</a>
</div>
<div class=”tab” id=”tab7″>

<br>
<br>
<input type=”radio” name=”3″ value=”option 1″> option 1<br>
<input type=”radio” name=”3″ value=”option 2″> option 2<br>
<input type=”radio” name=”3″ value=”option 3″> option 3<br>

<a href=”#tab1″ onclick=”tabber1.show(1); return false; “> Back</a>
</div>

<div class=”tab” id=”tab8″>

<br>
<br>
<input type=”radio” name=”4″ value=”option 1″> option 1<br>
<input type=”radio” name=”4″ value=”option 2″> option 2<br>
<input type=”radio” name=”4″ value=”option 3″> option 3<br>

<a href=”#tab1″ onclick=”tabber1.show(1); return false; “> Back</a>
</div>
<div class=”tab” id=”tab9″>

<br>
<br>
<input type=”radio” name=”5″ value=”option 1″> option 1<br>
<input type=”radio” name=”5″ value=”option 2″> option 2<br>
<input type=”radio” name=”5″ value=”option 3″> option 3<br>

<INPUT type=”submit” value=”Submit”>

</form>
<a href=”#tab1″ onclick=”tabber1.show(1); return false; “><br> Back</a>
</div>
</div>

</div>

<script type=”text/javascript”>
var tabber1 = new Yetii({
id: ‘tab-container-1’
});
</script>
<script type=”text/javascript”>

</script>
</body>

</html>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@wbportJul 01.2009 — I don't see where you are looking the checked value of the radio buttons. I use the following:
[CODE] if (document.tform.select1[0].checked == false) //Set for sequential players and min. moves
atype=1;
if (document.tform.select1[2].checked == true)
minmove=1;
if (document.tform.flipit[1].checked == true) // If set will swap the colors before they are displayed
flipcolors=1;
[/CODE]
in my [url=http://bellsouthpwp.net/w/b/wbport/chess_etc/crenshaw.htm]Round Robin[/url] page.

HTH
Copy linkTweet thisAlerts:
@hacketJul 02.2009 — This code will get the checked value of a radio group:

function checkIndGroup(radioGroup){

var value = ""

for(i=0;i<5;i++){

if(radioGroup[i].checked){

value=radioGroup[i].value}}

if(value==""){

alert("Nothing Checked!")

break

}

return value

}



This code will create what's called a 'textnode' and insert it into a table cell:



table = document.createElement("table")

tableBody = document.createElement("tbody")

currentRow = document.createElement("tr")

currentCell = document.createElement("td")

currentText = document.createTextNode("Value")

currentCell.appendChild(currentText)

currentRow.appendChild(currentCell)

tableBody.appendChild(currentRow)

table.appendChild(tableBody)

document.getElementById('whateverform').appendChild(table)







The entire series creates a table, a tablebody, a row, a cell, and a textnode. It then appends each to the former.



As far as changing a page without a reload, I'm not sure. I just started learning JS two weeks ago, but I believe AJAX has the potential to do that.
×

Success!

Help @laxbri08 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,
)...