Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form 10.3 | Q80 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.