Click to See Complete Forum and Search --> : Simple challenge


doodler
04-26-2003, 04:33 PM
<script language="javascript">
function newUrl()
{
var protocol = document.body.goer.q0.value;
var www = document.body.goer.q1.value;
var strID = document.body.goer.q.value;
var domain = document.body.goer.xyz.value;
var folder = document.body.goer.q2.value;
if (strID == "")
{
window.alert("Please type an domain name.");
}else{
if (strID.indexOf("://") < 1)
{
strID = protocol + www + "." + strID + domain + "/" + folder;
}
if(document.all.item("thisframe").checked==true){parent.header.location = strID;}
else{parent.main.location = strID;
}}}
</script>

<form method="GET" name="goer" id="goer" action="javascript:newUrl();">
<p align="center"><select size="1" name="q0" class="text">
<option selected value="http://">http://</option>
<option value="https://">https://</option>
<option value="ftp://">ftp://</option>
</select><input size="8" name="q1" value="www" class="text" style="text-align: center" >.

<input size="18" name="q" class="text" style="text-align: center"><font size="2"><b><select size="1"

name="xyz" class="text">
<option selected value=".com">.com</option>
<option value=".net">.net</option>
<option value=".org">.org</option>
<option value=".gov">.gov</option>
<option value=".edu">.edu</option>
<option>----------</option>
<option value=".co.uk">.co.uk</option>
<option value=".uk">.uk</option>
<option value=".org.uk">.org.uk</option>
<option value=".gov.uk">.gov.uk</option>
<option value=".edu.uk">.edu.uk</option>
<option value=".ac.uk">.ac.uk</option>
<option>----------</option>
<option value=".net.uk">.net.uk</option>
<option value=".com.uk">.com.uk</option>
<option>----------</option>
<option value=".name">.name</option>
<option value=".be">.be</option>
<option value=".cc">.cc</option>
<option value=".info">.info</option>
<option value=".biz">.biz</option>
<option value=".nu">.nu</option>
</select>/</b><input size="13" name="q2" class="text"><input type="checkbox" name="

thisframe" value="parent.header"></font><font size="1"><b>This
frame</b></font><font size="2">
<input type="submit" value="Load" class="button" style="font-size: 8pt"></font></p>
</form>

The above HTML code shows a page that has form elements that when the user types in the info such as domain name and so on, the user clicks the submit button to load a page in either the same frame or below frame.

TWO problems:
1) Doesn't work (something about the element not being there)
2) I need it to work in Netscape AND IE!!!! Doesnt matter about versions

Please help. I'm sure it's a simple problem :-)

khalidali63
04-26-2003, 04:50 PM
cmon..you can't resolve a "simple" problem..

jking
:D

doodler
04-26-2003, 04:52 PM
haven't got a clue

doodler
04-26-2003, 05:26 PM
i get a "top.header.location is null of not an object"?? This is on line 17 and could also be line 19. (getting there)

khalidali63
04-26-2003, 05:27 PM
here you go...

function newUrl(){
var protocol = document.goer.q0.options[document.goer.q0.selectedIndex].value;
var www = document.goer.q1.value;
var strID = document.goer.q.value;
var domain = document.goer.xyz.options[document.goer.xyz.selectedIndex].value;
alert("prtotcol="+protocol+"\nwww = "+www+"\nstrID = "+strID+"\ndomain = "+domain)
var folder = document.goer.q2.value;
if (strID == ""){
window.alert("Please type an domain name.");
}else{
if (strID.indexOf("://") < 1){
strID = protocol + www + "." + strID + domain + "/" + folder;
}
if(document.all.item("thisframe").checked==true){
alert(strID)
parent.location.href = strID;
}else{
parent.main.location = strID;
}
}
return false;
}
</script>

<form method="GET" name="goer" id="goer" action="javascript:newUrl();">
<p align="center">
<select size="1" name="q0" class="text">
<option selected value="http://">http://</option>
<option value="https://">https://</option>
<option value="ftp://">ftp://</option>
</select>
<input size="8" name="q1" value="www" class="text" style="text-align: center" >.
<input size="18" name="q" class="text" style="text-align: center"><font size="2"><b>
<select size="1" name="xyz" class="text">
<option selected value=".com">.com</option>
<option value=".net">.net</option>
<option value=".org">.org</option>
<option value=".gov">.gov</option>
<option value=".edu">.edu</option>
<option>----------</option>
<option value=".co.uk">.co.uk</option>
<option value=".uk">.uk</option>
<option value=".org.uk">.org.uk</option>
<option value=".gov.uk">.gov.uk</option>
<option value=".edu.uk">.edu.uk</option>
<option value=".ac.uk">.ac.uk</option>
<option>----------</option>
<option value=".net.uk">.net.uk</option>
<option value=".com.uk">.com.uk</option>
<option>----------</option>
<option value=".name">.name</option>
<option value=".be">.be</option>
<option value=".cc">.cc</option>
<option value=".info">.info</option>
<option value=".biz">.biz</option>
<option value=".nu">.nu</option>
</select>/</b>
<input size="13" name="q2" class="text">
<input type="checkbox" name="thisframe" value="parent.header"></font>
<font size="1"><b>This frame</b></font>
<font size="2">
<input type="submit" value="Load" class="button" style="font-size: 8pt">
</font></p>
</form>

</body>
</html>

doodler
04-26-2003, 05:33 PM
No, same error as above (parent.header is null blah blah) AND you can't use "document.all" in Netscape

doodler
04-26-2003, 05:40 PM
My frame set consists of just two horizontal frames (one over another otherwise known as a header)

What would i need to do to change the code to make it work? rename my frames?

doodler
04-26-2003, 05:49 PM
I have fixed it. THANK YOU!!