By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,704 Members | 1,299 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,704 IT Pros & Developers. It's quick & easy.

Passing variable...

P: n/a
I have a form like this:

<form name="dane" action="wyszukiwanie.php" method="post" onSubmit="return
<input maxlength="30" size="35" name="family_name" value="">
Now, How can I pass a value from this input to my js script verify_form() ??

And second question: if I have "radio" input im my form how can I check
using js if any option was chosen?


Jan 23 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
You can pass the reference to your form object with using 'this'
statement, e.g.

onSubmit="return verify_form(this)"
function verify_form(objForm)

or search for the form object in you function:

var objForm = document.getElementById("dane");

but in this case you should also expand form tag with option id="dane".

In any way usage of the object identical for both cases:

alert('Family_name value is ' + objForm.family_name.value);

To check that radio button were choosen:

<input type="radio" name="radio_button_name">Top
<input type="radio" name="radio_button_name">Middle
<input type="radio" name="radio_button_name">Bottom

use followin code:

if (objForm.radio_button_name[0].checked ||
objForm.radio_button_name[1].checked ||
alert('Some option were choosen!');

P.S. You can get complete help for DOM and JavaScript usage in MSDN.

Jan 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.