-1

I am using JAVASCRIPT

I am trying to figure out something from my homework.

I have to create a search for books library, and I want to know how can I have radio buttons and then pass its values to a Onclick button or submit button.

for example i have this function:

function searchByISBN() //Gets a book by its ISBN
    {
    var bookNumber = document.getElementById("isbn").value;
        var book = getBookByIsbn(bookNumber);
    showBooks(book);
    }

then I have a radio buttons like this (sorry about this mock up):

[text box. Where the user Enters information about the book]

Isbn X
author X
title X

[go button]

so If I select search by Isbn, How can i pass my function above mentioned to the go button.

thank you very much

Augusto
  • 19
  • 3
  • This can be useful: [http://www.homeandlearn.co.uk/php/php4p10.html](http://www.homeandlearn.co.uk/php/php4p10.html) – Eduardo M May 28 '13 at 03:23
  • http://stackoverflow.com/questions/1423777/how-can-i-check-whether-a-radio-button-is-selected-in-javascript – hol May 28 '13 at 03:43

1 Answers1

0

I'm not sure if I get this correct but you can do following to check if radio button is selected

HTML:

<form name="form">
<input type="radio" name="button">Book Button<br>
<button type="button" onclick="searchByISBN();">Check</button>
</form>

Javascript:

function searchByISBN() //Gets a book by its ISBN
    {
   if(document.form.button.checked)
     {
        alert("RadioButton is checked")
      }
    };
xhallix
  • 2,919
  • 5
  • 37
  • 55