Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q80 How can I pass checkbox or radio value to another page?

You are here: irt.org | FAQ | JavaScript | Form | 10.3 | Q80 [ previous next ]

The trick is to name all the form elements. That way when the form is submitted it will pass the name and value pair to the next page as part of the location, which can be accessed using the search property:

<form action="myPage.html">
Tick: <input type="checkbox" name="box1">
On: <input type="radio" name="radio1" value="on">
Off: <input type="radio" name="radio1" value="off">
<input type="submit">
</form>

And then in myPage.html:

<script language="JavaScript"><!--
var passed=window.location.search.substring(1);
alert(passed);
//--></script>

You then have to manipulate the string to access the names and values.

One point to remember - this facility of passing stuff between one page and another does not work offline when using MS Internet Explorer. It does online though.

Feedback on 'Q80 How can I pass checkbox or radio value to another page?'

©2018 Martin Webb