944,161 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
May 7th, 2007
0

JavaScript Help with display

Expand Post »
In one of my previous posts here I got the information on what I had to do. Now I have a similar problem instead of using a button to do that I have 2 links that when clicked will take you to the same page but depending on the link clicked certain options are going to be grayed out.

I just dont know how to get started on this. If any one can show me a good place to start that would be greatly apreciated.
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
edouard89 is offline Offline
53 posts
since Feb 2007
May 7th, 2007
0

Re: JavaScript Help with display

Use the disabled attribute.

Start with the basic html portion of a form (named "order"):
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <input type="text" id="quantity" disabled="disabled" />

Then, in JavaScript, you change the attribute to enable the field:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.forms.order.quantity.disabled = false;
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
May 8th, 2007
0

Re: JavaScript Help with display

I see, but how would it know which one has been clicked, because the two links both link to the same page and dependant of which is clicked the infromation will change.
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
edouard89 is offline Offline
53 posts
since Feb 2007
May 8th, 2007
0

Re: JavaScript Help with display

Fake the links with form input buttons:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <input type="button" id="quantity" name="ONE" onclick="javascript:menu1()" />
  2. <input type="button" id="quantity" name="TWO" onclick="javascript:menu2()" />
Then use the javascript to first open the window, then enable the proper devices:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function menu1(){
  2. theWindow = window.open('theurl.htm', 'theWin', '');
  3. theWin.focus();
  4. document.forms.order.quantity.disabled = false;
  5. .
  6. .
  7. .
Last edited by MidiMagic; May 8th, 2007 at 3:22 pm.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
May 9th, 2007
0

Re: JavaScript Help with display

I have an ASP page that uses

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. sub SetHoursMenu()
  2. Dim period, empid, url, url2, url3, RS
  3.  
  4. sub_menu = "<div class=""menu"" id=""submenu-hours"">"
  5. url = "Hours.asp"
  6. url2 = "HourMod.asp"
  7. url3 = "HourMod.asp"
  8. period = request.QueryString("period")
  9. if period <> "" then
  10. url = url&"?period="&period
  11. end if
  12. if IsAdmin then
  13. empid = request.QueryString("empid")
  14. if empid = "" then
  15. Set RS = Conn.Execute("SELECT * FROM users ORDER BY name")
  16. empid = RS("id")
  17. RS.Close
  18. Set RS = nothing
  19. end if
  20. if InStr(url, "?") then
  21. url = url&"&"
  22. else
  23. url = url&"?"
  24. end if
  25. url = url&"empid="&empid
  26. url2 = url2&"?empid="&empid
  27. url3 = url3&"?empid="&empid
  28. end if
  29. sub_menu = sub_menu&"<span>"&HyperLink(url, "<img src=""logs.gif"" width=""120"" height=""30"" id=""logsbutton"" />")&"</span>"
  30. sub_menu = sub_menu&"<span onclick=""javascript:menu1()"">"&HyperLink(url2, "<img src=""img/companyhours.jpg"" width=""120"" height=""30"" id=""addbutton"" />")&"</span>"
  31. sub_menu = sub_menu&"<span onclick=""javascript:menu2()"">"&HyperLink(url3, "<img src=""img/noncompanyhours.jpg"" width=""120"" height=""30"" id=""addbutton"" />")&"</span></div>"
  32.  
  33. end sub

To generate the URL for the links. My problem is that I dont know how to transfer that URL to the javascript function in order for it to display the page. Otherwise when the function opens a new window it tells me to relogin if it just use the "HourMod.asp" as the url. When the page loads the url is suposed to look something like this:

[HTML]http://....... edtemp/HourMod.asp?empid=1&sid=E3BCB8594C5F8EDF7A86CDD50266B6964196[/HTML]

And by the way is there a way of doing this without opening a new window?
Thanks,
Last edited by edouard89; May 9th, 2007 at 10:45 am.
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
edouard89 is offline Offline
53 posts
since Feb 2007
May 10th, 2007
0

Re: JavaScript Help with display

You could pass the url as a parameter.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <input type="button" id="quantity" name="ONE" onclick="javascript:menu1(url1.htm)" />
  2. <input type="button" id="quantity" name="TWO" onclick="javascript:menu2(url2.htm)" />

Wouldn't it be easier to just have two versions of the page?
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
May 10th, 2007
0

Re: JavaScript Help with display

Yes it would be a lot easier to make two pages but this is what I have to do. This is what I have done on this

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. response.Write "function menu1(txt)"
  2. response.Write "{"
  3. response.Write "theWindow=window.open(txt, 'theWin', '');"
  4. response.Write "theWin.focus();"
  5. response.Write "document.forms.Hours.nonCompany.disabled = true;"
  6. response.Write "}"
  7. response.Write "function menu2(txt)"
  8. response.Write "{"
  9. response.Write "theWindow=window.open(txt, 'theWin', '');"
  10. response.Write "theWin.focus();"
  11. response.Write "document.forms.Hours.nonCompany.disabled = false;"
  12. response.Write "document.forms.Hours.nonCompany.checked = true;"
  13. response.Write "}"

but when I use it with the buttons on the top

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. sub_menu = sub_menu&"<span onclick=""javascript:menu1(url2)""><img src=""img/companyhours.jpg"" width=""120"" height=""30"" id=""addbutton"" /></span>"
  2.  
  3. sub_menu = sub_menu&"<span onclick=""javascript:menu2(url3)""><img src=""img/noncompanyhours.jpg"" width=""120"" height=""30"" id=""addbutton"" /></span></div>"

It gives me an error saying that either url2 or url3 is undefined. I dont know weather this is because of the way I am using the the url2/url3 as parameters or something else.

I apreciate your help very much thank you.
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
edouard89 is offline Offline
53 posts
since Feb 2007
May 10th, 2007
0

Re: JavaScript Help with display

I think I know that my problem is in the fact that I am using a variable and not the actual URL, My question now is if its possible to use that as a parameter because of most of the function tutorials I have looked at always have an exact value and not a variable.
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
edouard89 is offline Offline
53 posts
since Feb 2007
May 11th, 2007
0

Re: JavaScript Help with display

The url should be in single quotes when passed as a parameter. It is text at that point.

What do you mean you "have to" do it that way? You got a nut for a boss?
Last edited by MidiMagic; May 11th, 2007 at 4:49 am.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
May 11th, 2007
0

Re: JavaScript Help with display

I am having trouble with the URL bieng used as a parameter. Is there a way that I can use javascript to get a value from vbscript and return that value from the vbscript to be used by the java script?

for example:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <span onclick=""javascript:menu1(VBFUNCTION HERE)"">
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. response.Write "function menu1(txt)"
  2. response.Write "{"
  3. response.Write "theWindow=window.open(txt, 'theWindow', '');"
  4. .
  5. .
  6. .

The VBfunction would then return a value that would be used to open the new window. Or open the page in the same window?
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
edouard89 is offline Offline
53 posts
since Feb 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: quick javascript help
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Help using looping in JS





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC