JavaScript Help with display

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Feb 2007
Posts: 53
Reputation: edouard89 is an unknown quantity at this point 
Solved Threads: 2
edouard89's Avatar
edouard89 edouard89 is offline Offline
Junior Poster in Training

JavaScript Help with display

 
0
  #1
May 7th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: JavaScript Help with display

 
0
  #2
May 7th, 2007
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;
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 53
Reputation: edouard89 is an unknown quantity at this point 
Solved Threads: 2
edouard89's Avatar
edouard89 edouard89 is offline Offline
Junior Poster in Training

Re: JavaScript Help with display

 
0
  #3
May 8th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: JavaScript Help with display

 
0
  #4
May 8th, 2007
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.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 53
Reputation: edouard89 is an unknown quantity at this point 
Solved Threads: 2
edouard89's Avatar
edouard89 edouard89 is offline Offline
Junior Poster in Training

Re: JavaScript Help with display

 
0
  #5
May 9th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: JavaScript Help with display

 
0
  #6
May 10th, 2007
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?
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 53
Reputation: edouard89 is an unknown quantity at this point 
Solved Threads: 2
edouard89's Avatar
edouard89 edouard89 is offline Offline
Junior Poster in Training

Re: JavaScript Help with display

 
0
  #7
May 10th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 53
Reputation: edouard89 is an unknown quantity at this point 
Solved Threads: 2
edouard89's Avatar
edouard89 edouard89 is offline Offline
Junior Poster in Training

Re: JavaScript Help with display

 
0
  #8
May 10th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: JavaScript Help with display

 
0
  #9
May 11th, 2007
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.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 53
Reputation: edouard89 is an unknown quantity at this point 
Solved Threads: 2
edouard89's Avatar
edouard89 edouard89 is offline Offline
Junior Poster in Training

Re: JavaScript Help with display

 
0
  #10
May 11th, 2007
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?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC