0

I am declaring 5 checkbox values in myform with the name as "yourname". On clicking submit button javascript function will be called.

In the JS function, I need to pass this value into parent window.

MyHTML Code is:

<input type="checkbox" name="yourname" value="ankit">Ankit<br/>
<input type="checkbox" name="yourname" value="rahul">Rahul<br/>

.. and more

<input type=button value='Submit' onclick="post_value();">

For Example, Using Below JS Code will print all values to the parent window.

function post_value(){
    var yourname = ["ankit","rahul","vipin","abhishek"];
    alert(yourname);
    opener.document.f1.p_name.value = yourname;
    self.close();
}

Kindly Help,

3
  • Please use code sample button to format your code samples. Commented Jan 12, 2011 at 11:23
  • Not sure what exactly you're trying to accomplish here, but you surely should be using radio buttons for that purpose. Can you clarify a bit what you're trying to accomplish? Commented Jan 12, 2011 at 11:36
  • I had two categories(Articles,Career) They would appear as: +Articles +Career. On Clicking a particular Category, list of subcategories would appeared in checkboxes. I am doing this for first time. Can i know where to start? Thanks Commented Jan 13, 2011 at 7:21

1 Answer 1

2

Give id to all your checkboxes and Check which one is checked using document.getElementById('checkBoxId').checked

This will return you true/false.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.