VBScript t o JScript

Results 1 to 7 of 7

Thread: VBScript t o JScript

  1. #1
    minnie Guest

    Default VBScript t o JScript

    I&#039m new to JavaScript.<BR>I am trying to pull up a calendar on the click event of the text box.<BR>I have the following code in VBScript.<BR>&#060;script Language="VBScript"&#062;<BR>sub txtDate_onclick()<BR> if Trim(frmname.txtdate.value) = "" then<BR> calpopup("../Calender/DateSelect.asp? Page=BODY&Form=frmName&Element=txtDate")<BR> else<BR>calpopup("../Calender/DateSelect.asp?Page=BODY&Form=frmName&Element=txtD ate&DispDate=" + frmName.txtDate.Value )<BR>End If<BR>End Sub<BR>&#060;/Script&#062;<BR>//**Calpopup is my function which pulls up a calender!<BR>I would like to write the above code in JavaScript.<BR>Please Help!!!<BR><BR>

  2. #2
    MChance Guest

    Default RE: VBScript t o JScript

    Here you go:<BR><BR>&#060;SCRIPT LANGUAGE="JavaScript"&#062;<BR>function calPop() {<BR><BR> if (frmname.txtdate.value == "") {<BR> calpopup("../Calender/DateSelect.asp? Page=BODY&Form=frmName&Element=txtDate");<BR> }else{<BR> calpopup("../Calender/DateSelect.asp?Page=BODY&Form=frmName&Element=txtD ate&DispDate=" + frmName.txtDate.Value );<BR> }<BR>}<BR>&#060;/SCRIPT&#062;<BR><BR>Can&#039t seem to get the code to indent, so, sorry it&#039s not that readable.<BR><BR>This will not work with Netscape browsers because they don&#039t know what "frmname.txtdate.value" is. You would need to test the browser type and then change that line to be document.frmname.txtdate.value for Netscape users. Otherwise this should work fine.<BR><BR>Hope this helps.<BR><BR>Mark Chance

  3. #3
    minnie Guest

    Default RE: VBScript t o JScript

    the calender didn&#039t popup in Netscape though I was using document.frmname.txtdate.value<BR><BR>for the function Calpopup I have the following code.<BR><BR>function calpopup(lnk)<BR>{<BR>window.open(lnk,"Calender"," height=250,width=250,scrollbars=no");<BR>}<BR><BR> <BR>However it works fine with IE.<BR><BR>thanks for your help.

  4. #4
    ASP_DRUG_DEALER Guest

    Default RE: VBScript t o JScript

    Hmmm, Should of worked....<BR>Try this?<BR>&#060;Head&#062;<BR>&#060;script&#062; <BR> &#060;!-- <BR> function open_window(url) { <BR> window.open(url,"NewWindow",&#039toolbar=0,locatio n=0,directories=0,status=0,menubar=0,scrollbars=ye s,resizable=0,width=350,height=300&#039);<BR> } <BR> // --&#062; <BR>&#060;/script&#062; <BR>&#060;/Head&#062;<BR><BR>To call it...<BR>&#060;A HREF="javascript:open_window(&#039anothergreatpage .asp&#039)"&#062;For a cool pop-up window to another page!&#060;/A&#062;<BR><BR>Works in NS 3,4, IE 4 and up. Have not had a chance to check it out in IE3?<BR><BR>Hope this helps.<BR>


  5. #5
    MChance Guest

    Default RE: VBScript t o JScript

    The other "quirk" with Netscape is if the form is on a layer. If it is, you need to refer to it as:<BR><BR>document.layerName.document.frmName.txt Date.value<BR><BR>Just in case.<BR><BR>Mark Chance

  6. #6
    minnie Guest

    Default RE: VBScript t o JScript

    what do you mean by layer?<BR>I just have a form and a text box in it so when I&#039m using<BR>document.formname.text1.value<BR><BR>is this okay??<BR><BR>thanks<BR>

  7. #7
    MChance Guest

    Default RE: VBScript t o JScript

    A Layer is created using the &#060;DIV&#062;&#060;/DIV&#062;, &#060;LAYER&#062;&#060;/LAYER&#062;, &#060;ILAYER&#062;&#060;/ILAYER&#062; tags. All of these are tags used to create a layer. A lot of WYSIWYG editors and the Word-&#062;HTML convertor tend to use the &#060;DIV&#062; tag in place of other, more appropriate tags.<BR><BR>If you don&#039t see any of these around your form, yes, "document.formname.txtdate.value" should work.<BR><BR>Another reason it may not be working is how you are identifying your forms. Make sure you have a NAME attribute added. Netscape does not look at the ID attribute, so make sure you do this:<BR><BR>&#060;FORM NAME="frmname" ...etc.&#062; Netscape only looks at the NAME tag for the form name. If, for some reason you don&#039t want to add the NAME attribute, you can access the form and it&#039s elements through the document&#039s forms array and the form&#039s elements array like this:<BR><BR>document.forms[0].elements[0].value<BR><BR>Assuming you only have one form on your page and the txtDate field is the first element DEFINED in the form. Form elements are added to the elements array in the order they are defined.<BR><BR>Hope this makes sense, and helps.<BR><BR>Mark Chance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •