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

pass variable with javascript

Status
Not open for further replies.

TRACEYMARYLAND

Programmer
May 21, 2004
370
US
First page
What im trying to do is update the input name
of FIELD_ID_<%=rs("FIELD_ID")%> with what i select from the window.


<td width="<%=rs("FIELDNAMESPACE")%>" border="<%=TRIM(rs("BORDERSIZE"))%>" bordercolor="<%=TRIM(rs("BORDERCOLOR"))%>" bgcolor="<%=TRIM(rs("BGCOLOR"))%>" >
<input name="FIELD_ID_<%=rs("FIELD_ID")%>" type="text" size="<%=rs("FIELDNAMESIZE")%>" <%if request("AmendDetails") = "Y" then %>value="<%=rs("FIELD_TEXT")%>" <%end if%> maxlength="300">

<img src="../searchc.jpg" width="20" height="20" border="0" onClick="open_win('test_call.asp',400,400,0,0,0,0,0,1,0,0,5,'Search'); return false;">

</td>

window
<a href="javascript:window.opener.document.form1['FIELD_ID_388'].value='<%=rs("FIELDNAME")%>';self.close();"><%=rs("FIELDNAME")%></a>

Now if i put in the actual value FIELD_ID_388 it works great

Now i like to be able to pass in the value of 388 into the javascript parameters so that i can update any input value ...so if im on 389 it updates 389.

Window

function open_win(what_link,the_x,the_y,toolbar,addressbar,directories,statusbar,menubar,scrollbar,resize,history,pos,wname){
var the_url = what_link;
the_x -= 0;
the_y -= 0;
var how_wide = screen.availWidth;
var how_high = screen.availHeight;
if(toolbar == "0"){var the_toolbar = "no";}else{var the_toolbar = "yes";}
if(addressbar == "0"){var the_addressbar = "no";}else{var the_addressbar = "yes";}
if(directories == "0"){var the_directories = "no";}else{var the_directories = "yes";}
if(statusbar == "0"){var the_statusbar = "no";}else{var the_statusbar = "yes";}
if(menubar == "0"){var the_menubar = "no";}else{var the_menubar = "yes";}
if(scrollbar == "0"){var the_scrollbars = "no";}else{var the_scrollbars = "yes";}
if(resize == "0"){var the_do_resize = "no";}else{var the_do_resize = "yes";}
if(history == "0"){var the_copy_history = "no";}else{var the_copy_history = "yes";}
if(pos == 1){top_pos=0;left_pos=0;}
if(pos == 2){top_pos = 0;left_pos = (how_wide/2) - (the_x/2);}
if(pos == 3){top_pos = 0;left_pos = how_wide - the_x;}
if(pos == 4){top_pos = (how_high/2) - (the_y/2);left_pos = 0;}
if(pos == 5){top_pos = (how_high/2) - (the_y/2);left_pos = (how_wide/2) - (the_x/2);}
if(pos == 6){top_pos = (how_high/2) - (the_y/2);left_pos = how_wide - the_x;}
if(pos == 7){top_pos = how_high - the_y;left_pos = 0;}
if(pos == 8){top_pos = how_high - the_y;left_pos = (how_wide/2) - (the_x/2);}
if(pos == 9){top_pos = how_high - the_y;left_pos = how_wide - the_x;}
if (window.outerWidth ){
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
wname=window.open(the_url, wname, option);
wname.focus();
}
else
{
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
if (!wname.closed && wname.location){
wname.location.href=the_url;
}
else
{
wname=window.open(the_url, wname, option);
//wname.resizeTo(the_x,the_y);
wname.focus();
wname.location.href=the_url;
}
}
}


Is this at all possible.

Cheers
 
>>Now i like to be able to pass in the value of 388 into the javascript parameters so that i can update any input value


save the value in a hidden field, in ur popup refer the value as:
TheField=window.opener.documen.forms['HiddenField'].value

//this will return 388 and so on:
TheField=window.opener.documen.forms[TheField]

//TheField is the field that u are looking for...

Known is handfull, Unknown is worldfull
 
vbkris thanks for replying
can you explain a little more.

Which page do i do the hidden field...the firstpage or the window itself

I have about 20 windows to write...and pass the value back to which ever field your on.

Thanks
 
i have managed this

parent window
<input name="FIELD_ID_<%=rs("FIELD_ID")%>" type="text" size="<%=rs("FIELDNAMESIZE")%>" <%if request("AmendDetails") = "Y" then %>value="<%=rs("FIELD_TEXT")%>" <%end if%> maxlength="300">
<img src="../searchc.jpg" width="20" height="20" border="0" onClick="open_win('test_call.asp',400,400,0,0,0,0,0,1,0,0,5,'Search'); return false;">

child window

in here i set
<%setValue = 277%>
<a href="javascript:window.opener.document.form1.FIELD_ID_<%=setValue%>.value='<%=rs("FIELDNAME")%>';self.close();"><%=rs("FIELDNAME")%></a>

Now all i have to do is when there on this field
some how set ....setValue = actual field_id

Any ideas how to set the setValue
Can i do another call just before the onclick(
 
<input type="hidden" value="FIELD_ID_<%=rs("FIELD_ID")%>" name="h1">

in the popup window:
TheField=window.opener.documen.forms['H1'].value
//this will return FIELD_ID_388 etc

TheField=window.opener.documen.forms[TheField]

alert(TheField.value)


does this give u the value of the field that u want???

Known is handfull, Unknown is worldfull
 
Typo there?
Code:
opener.documen[red][b]t[/b][/red]...

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Thanks
I actually did this in the end
pass the fieldid in the url
<%if rs("WINDOWNAME") > "" then
windowcall = rs("WINDOWNAME") + ".asp"%>
<img src="../searchc.jpg" width="20" height="20" border="0" onClick="open_win('<%=windowcall%>?FieldId=<%=rs("FIELD_ID")%>',600,600,0,0,0,0,0,1,0,0,5,'Search'); return false;">
<%end if%>

I suppose the same as a hidden name but my form could change on different form
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top