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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange problem

Status
Not open for further replies.

beco73

Programmer
May 8, 2005
157
CA
Hi,

Do you see anything wrong with the following code?


<script language="JavaScript" type="text/javascript">
function validatephonemodel()
{

if (document.getsearch.model.value == "")
{ alert ("Please enter the phone model");}
else

{
a=document.getsearch.model.value;
var lineurl="searchphonemodel.php?model=" + a
location.href=lineurl
}

}

</script>

*************

I have complained by some one that they are geting error because URL it is creating has no variable
it is creating
instead of
How can that be possible?
I am not having any problem I am using IE 6.0.2800

they are using IE 6.0.2900.2180
 
You do not declare a as a var unless it is elsewhere in the code.
If no value exists or the code is unable to retrieve the value for document.getsearch.model then the URL would be:

Perhaps that is what they meant when they said it had no variable?

You may be better off using document.getElementById('model').value to get the value but you will of course have to ensure that the field has an ID rather than just name.


Stamp out, eliminate and abolish redundancy!
 
Did you copy/paste the code-snippet above? Perhaps your customer's version of IE is a tiny bit more sensitive to the absence of a semi-colon at the end of the line before the re-direct...?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
There too, yes, but I was actually talking about the line before:

var lineurl="searchphonemodel.php?model=" + a[!];[/!]

By the way, is the url they are re-directing to... the SAME PAGE as the one they're on? That could be a clue.

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
No it is redirecting to different page

I will try with semi colon, I think thats what the problem is.

Now they are using IE 6.0.2900.2180, which is new version than what i am using 6.0.2800, may be they did not have service packs installed

 
Maybe you should prepare the string "a" more apt to pass to the url. Like this in the else part.
[tt]
a=document.getsearch.model.value;
a=a.replace(/ /g,"+");
a=escape(a);
var lineurl="searchphonemodel.php?model=" + a;
[/tt]
Terminating with ; is good practice, but it should not be the problem here.
 
I have complained by some one that they are geting error because URL it is creating has no variable
it is creating www.xyz.searchphonemodel.php

This might also happen if the browser they are using has scripting disabled, and the form is using the POST method.

Can you check to see if they have scripting disabled?

Dan




[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Yes the code is like this that called the function

<form name="getsearch" method="post" action="searchphonemodel.php">

<input type="text" name="model" class="form100"><br>
<a href='javascript:validatephonemodel();'><img SRC='images/search.jpg' width='68' height="24" border="0" align="absmiddle"></a>
</form>


I made the follwing change that did not make any difference.

<script language="JavaScript" type="text/javascript">
function validatephonemodel()
{

if (document.getsearch.model.value == "")
{ alert ("Please enter the phone model");}
else

{
a=document.getsearch.model.value;
var lineurl="searchphonemodel.php?model=" + a;
location.href=lineurl;
}

}

</script>


, I yet to try tsuji's code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top