Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Not Working 4

Status
Not open for further replies.

benkov

Programmer
Jun 16, 2004
13
GB
Hello,

I am a rookie javascripter (using pre-made scripts) and have edited a script slightly, but it is now returning an error.
Perhaps someone could check it over and tell me what is wrong

Thanks


<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

<script language="javascript">
<!--//
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.pass.value=="0712") {
location="page2.html"
} else {
alert("Invalid Password")
}
}
}
//-->
</script>

<center>
<table bgcolor="white" cellpadding="12" border="1">
<tr><td colspan="2"><center><h1><i><b>Login
Area</b></i></h1></center></td></tr>
<tr><td><h1><i><b>Password:</b></i></h1></td><td><input name="pass"
type="password"></td></tr>
<tr><td><center><input type="button" value="Login"
onClick="pasuser(this.form)"></center></td><td><center><br><input
type="Reset"></form></td></tr></table></center>
<script language="JavaScript">
<!--
var SymRealOnLoad;
var SymRealOnUnload;

function SymOnUnload()
{
window.open = SymWinOpen;
if(SymRealOnUnload != null)
SymRealOnUnload();
}

function SymOnLoad()
{
if(SymRealOnLoad != null)
SymRealOnLoad();
window.open = SymRealWinOpen;
SymRealOnUnload = window.onunload;
window.onunload = SymOnUnload;
}

SymRealOnLoad = window.onload;
window.onload = SymOnLoad;

//-->
</script>

 
Do you have anywhere in your code something that looks simular to this:

Code:
<input type="hidden" value="anything" id="pState" />


???

If so, then can you post the relevant code, HTML and Javascript so we can see what is going on?

From what I see, pState doesn't exist at the time this function is called, or may not exist at all.

[monkey][snake] <.
 
oops,

Sorry about posting on someone else's post.

Never did that before. I meant to start a new one.

Anyway,

Thanks for responding.

HTML code
Code:
... relavent code below
<td style="width: 93px"><input name="pState" id="pState" type="hidden" value="<%=st%>"></td>
<td style="width: 173px"><input name="PropCnty" id="PropCnty" type="hidden" value="<%=cty%>"></td>
<td style="width: 115px">&nbsp;</td>
<td align="center" style="width: 176px"><input type="submit" tabindex="7" value="Begin Search" style="font-size:11px">&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
</form>

Also,

I have tried changing the name/id, I have tried changing it from hidden to visible.

Thanks
 
Since I see ASP, are you calling that table conditionally??

Something like

Code:
<%
   If (dirty = "dog") then 
      %>
          <form> 
             <table>          
                <tr>          
                   <td style="width: 93px"><input name="pState" id="pState" type="hidden" value="<%=st%>"></td>
                   <td style="width: 173px"><input name="PropCnty" id="PropCnty" type="hidden" value="<%=cty%>"></td>
                </tr>
             </table>
          </form>
      <%
   EndIf
%>

I'll make a bet that this is what you are doing. In this case, there is no existance of the hidden variable pState if dirty does not equal "dog".

[monkey][snake] <.
 
I looked and I looked, but I didn't see anything that would prevent the input from existing.
 
It is quite a bit of code, I will try a little harder. I think I may go about it another way.

Thanks for all of your help.
 
Some things to check:

- Make sure you only have ONE element with the id of "pState"

- Try removing the name attribute of "pState" on the existing element

- Make sure when you view your client-side source ("View Source" in your browser) that you have an element with an ID attribute of "pState" (and only one element at that).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
BillyRay and Monksnake:

Sorry about not getting back, I only was able to solve the problem yesterday late.

I followed your suggetions, Dan, to view the page source, which helped me diagnose the problem.

The solution was doing a number of things in which one of them was to place and If statement around the javascript function call.

Code:
If Len(Request.Querystring("pNumber")) > 1 Then
%>
<script type="text/javascript">
	ChangeSelCounty('<%=Session("overview_county")%>');
</script>
<%
End If

I also moved around some previous ASP code and placed it earlier in the page load.

Sorry that I can't be more specific about the exact fix.

Thanks again to the both of you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top