PDA

View Full Version : javascript and radio buttons converturl



treeeen
02-05-2010, 11:20 PM
I'm hoping someone can tell me where I'm going wrong with the following. Everything seems to work just fine until I added the ability to specify a filetype. This form gives the user a text box to enter their search terms, a hidden field with some boolean elements for the search, a radio button to choose pdf, doc, or txt and a submit button. If I remove the filetype option from the html and scripting it works just fine. So, this has to be my problem. I'm getting undefined errors. I'm very new with javascript, so this is probably something simple that I'm missing. Thanks in advance for any help or suggestions!

<code>
<form action="http://www.bing.com/search"
onsubmit="this.q.value += (this.url.value + ' ' + this.city.value + this.filetype1.value); return true;">
<input type="hidden" name="q"
value="music classic " />
<table class="style1">
<tr>
</td>
</td>
</td>
<td> </td>
</tr>
<tr>

<td class="style2">
<label><input name="url" type="text" style="width: 176px" /></label></td>
<td class="style3"><label><select name="city" class="c1">
<option value="Dallas" selected="selected">Dallas</option>
<option value="">Nationwide</option>
<option value="Atlanta">Atlanta</option>
<option value="Austin">Austin</option>
<option value="Boston">Boston</option>

</select></label></td>
<td><input type="submit" name="search" value="Search" /></td>
</tr>
<tr>
<td></td>
<td>
<input id="radio" checked="checked" name="filetype1" type="radio" value="filetype:doc"
class="style6" /><span class="style6">.doc
</span>
<input id="radio1" name="filetype1" type="radio" value="filetype:pdf"
class="style6" /><span class="style6">.pdf
</span>
<input id="radio2" name="filetype1" type="radio" value="filetype:txt"
class="style6" /><span class="style6">.txt
</span>
</td>
</tr>
</table>
</form>

<script type="text/javascript">
function converturl() {
frm = document.forms[0];
return frm.f.value + + +
frm.fullurl.value +
frm.url.value + '+' +
frm.city[frm.city.selectedIndex].value + '+' +
frm.filetype1[frm.filetype1.selectedRadio].value + '+'+
frm.url.value;
}
</script></code>