/    Sign up×
Community /Pin to ProfileBookmark

jscript runtime error

i’ve attached the my code for opening a window vich has a calendar & buttons …& the selected date on this window is used in another form….

i’m getting the jscript runtime error:object expected
cud someone please go through the code & help me out

[upl-file uuid=72becd1b-5826-4d7f-a227-b059d6bbdbe7 size=4kB]code.txt[/upl-file]

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@BillyRayAug 10.2004 — Maybe you could tell us when the error occurs? Not having an ASP host makes it hard to run the code you attached. Maybe you have it online at a URL we can visit?

The only JavaScript I would change is the first line in your SetDate function... From this:

eval('var theform = document.' + formName + ';');
to this:

var theform = document.forms[formName];
Hope this helps,

Dan
Copy linkTweet thisAlerts:
@swatidauthorAug 10.2004 — it hasnt worked ...i'm still gettin the same error...the error is occuring in that setdate function only ....

anyways...thanx for the help
Copy linkTweet thisAlerts:
@BillyRayAug 10.2004 — You haven't shown the code where SetDate is being called. Maybe the ID you're passing in doesn't exist as the name of a form element?

Dan
Copy linkTweet thisAlerts:
@swatidauthorAug 10.2004 — this is my setdate function....

function SetDate(formName, id, newDate, postBack)

{

eval('var theform = document.' + formName + ';');

popUp.close();

theform.elements[id].value = newDate;

if (postBack)

__doPostBack(id,'');

}
Copy linkTweet thisAlerts:
@BillyRayAug 10.2004 — I know - you already posted it. What you didn't post is where it is being called from. :rolleyes:

Dan
Copy linkTweet thisAlerts:
@swatidauthorAug 10.2004 — o...sorry...i misread ur messg...

i wrote it in the code behind for my calendar window...adding an attribute to the button...onclick & called the function setdate
Copy linkTweet thisAlerts:
@BillyRayAug 10.2004 — OK - we'll play it your way. If you won't post the code surrounding the call to the SetDate function, perhaps you can tell us whether or not the IDs you are passing into the setDate function exist as valid form element names.

Come on - help us to help you!

Dan
Copy linkTweet thisAlerts:
@swatidauthorAug 11.2004 — This is my code behind

Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

If Not Page.IsPostBack Then

Dim selected As String = Request.QueryString("selected")

Dim id As String = Request.QueryString("id")

Dim form As String = Request.QueryString("formname")

Dim postBack As String = Request.QueryString("postBack")

Try
Cal.SelectedDate = CDate(selected)
Cal.VisibleDate = Cal.SelectedDate
Catch
Cal.SelectedDate = DateTime.Today
Cal.VisibleDate = Cal.SelectedDate
End Try


SelectCorrectValues()


OKButton.Attributes.Add("onClick", "window.opener.SetDate('" + form + "','" + id + "', document.Calendar.datechosen.value," + postBack + ");")


CancelButton.Attributes.Add("onClick", "CloseWindow()")

End If

End Sub 'Page_Load

Public Sub SelectCorrectValues()
lblDate.Text = Cal.SelectedDate.ToShortDateString()
datechosen.Value = lblDate.Text

End Sub 'SelectCorrectValues

Public Sub Cal_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cal.SelectionChanged
Cal.VisibleDate = Cal.SelectedDate
SelectCorrectValues()
End Sub 'Cal_SelectionChanged


End Class

[COLOR=red] OKButton.Attributes.Add("onClick", "window.opener.SetDate('" + form + "','" + id + "', document.Calendar.datechosen.value," + postBack + ");")[/COLOR]
Copy linkTweet thisAlerts:
@BillyRayAug 11.2004 — So we are [b]still[/b] none the wiser as to what "id" is being passed in as.

How about you debug the code with alert statements, and find out what "id" is being passed in as - and then see if it is a valid form element name.

Hope this helps,

Dan
Copy linkTweet thisAlerts:
@swatidauthorAug 11.2004 — id is passed in as txtdate

form as .... Form1...

newdate as..... selected date in the cal

postback....true

i dont see anything wrong in the values passed to the setdate...
Copy linkTweet thisAlerts:
@BillyRayAug 11.2004 — Both your form and form elements have ID attributes but no NAME attribute. I'd suggest adding name="Form1" to your form tag and name="txtDate" to your textbox.

Furthermore, JS is case sensitive, so passing "txtdate" when the name is "txtDate" will not work.

Hope this helps,

Dan
×

Success!

Help @swatid spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...