I just started learning javascript and I wanted to make an interface to the google search engine. I went on to implement the feature that filters languages and I found that I need to use a radio button set to do this.
I have looked around for ways to get values from radiobutton sets. I seem to always come across this one method..:
<input type="radio" onClick="someFunction('value')">
// then the function would have the 'value' parameter..
I want to be able to (within js) use the value of the box that is checked. My method (that failed?) can be found here:
// the javscript part::
function searchgoogle(){
var url=window.document.googleform.url.value.split(" "
;
var output="";
var lang="";
var options=window.document.googleform.language.length;
for (i=0; i<=options; i++){
if (window.document.googleform.language){
lang = window.document.googleform.language.value;
}
}
for (i=0; i<=url.length; i++){
output+="+"+url;
}
output=output.substr(1,output.length-11);
window.open("}
<!-- the html:: -->
<form name="googleform">
<input type="text" name="url">
<a href="javascript:searchgoogle()">Search</a> | <a href="javascript:reseturl()">Reset</a>
<br />
<input type="radio" name="language" value="&lr=lang_en">English
<input type="radio" name="language" value="&lr=lang_de">German
<br /><br />/* Looking for features to add... */
</form>
If you want to see the site live, its here:
Thanks for your time..
-Zach Ngo
I have looked around for ways to get values from radiobutton sets. I seem to always come across this one method..:
<input type="radio" onClick="someFunction('value')">
// then the function would have the 'value' parameter..
I want to be able to (within js) use the value of the box that is checked. My method (that failed?) can be found here:
// the javscript part::
function searchgoogle(){
var url=window.document.googleform.url.value.split(" "
var output="";
var lang="";
var options=window.document.googleform.language.length;
for (i=0; i<=options; i++){
if (window.document.googleform.language){
lang = window.document.googleform.language.value;
}
}
for (i=0; i<=url.length; i++){
output+="+"+url;
}
output=output.substr(1,output.length-11);
window.open("}
<!-- the html:: -->
<form name="googleform">
<input type="text" name="url">
<a href="javascript:searchgoogle()">Search</a> | <a href="javascript:reseturl()">Reset</a>
<br />
<input type="radio" name="language" value="&lr=lang_en">English
<input type="radio" name="language" value="&lr=lang_de">German
<br /><br />/* Looking for features to add... */
</form>
If you want to see the site live, its here:
Thanks for your time..
-Zach Ngo